dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection MemberInfoS


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection MemberInfoSerializationHolder.cs, NONE, 1.1 ClrConstructor.cs, 1.5, 1.6 ClrEvent.cs, 1.5, 1.6 ClrField.cs, 1.6, 1.7 ClrMethod.cs, 1.7, 1.8 ClrProperty.cs, 1.5, 1.6 ClrType.cs, 1.19, 1.20
Date: Thu, 21 Aug 2003 23:04:09 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection
In directory subversions:/tmp/cvs-serv23694/runtime/System/Reflection

Modified Files:
        ClrConstructor.cs ClrEvent.cs ClrField.cs ClrMethod.cs 
        ClrProperty.cs ClrType.cs 
Added Files:
        MemberInfoSerializationHolder.cs 
Log Message:


Serialization support for reflection classes.


--- NEW FILE ---
/*
 * MemberInfoSerializationHolder.cs - Implementation of the
 *                      "System.MemberInfoSerializationHolder" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Reflection
{

#if CONFIG_SERIALIZATION

using System.Runtime.Serialization;
using System.Reflection;
using System.Private;

// This class is used as a proxy to stand in type members such as
// fields, methods, properties, etc.  This class must be named
// "System.Reflection.MemberInfoSerializationHolder" for compatibility
// with other serialization implementations.

internal class MemberInfoSerializationHolder : ISerializable, IObjectReference
{
        // Internal state.
        private MemberTypes memberType;
        private String name;
        private String signature;
        private String assemblyName;
        private String className;

        // Constructor.
        public MemberInfoSerializationHolder(SerializationInfo info,
                                                                        
StreamingContext context)
                        {
                                if(info == null)
                                {
                                        throw new ArgumentNullException("info");
                                }
                                memberType = 
(MemberTypes)(info.GetInt32("MemberType"));
                                name = info.GetString("Name");
                                signature = info.GetString("Signature");
                                assemblyName = info.GetString("AssemblyName");
                                className = info.GetString("ClassName");
                        }

        // Serialize a unity object.
        public static void Serialize(SerializationInfo info,
                                                                 MemberTypes 
memberType,
                                                                 String name, 
String signature,
                                                                 Type 
containingType)
                        {
                                
info.SetType(typeof(MemberInfoSerializationHolder));
                                info.AddValue("Name", name);
                                info.AddValue("AssemblyName", 
containingType.Assembly.FullName);
                                info.AddValue("ClassName", 
containingType.FullName);
                                info.AddValue("Signature", signature);
                                info.AddValue("MemberType", (int)memberType);
                        }

        // Implement the ISerializable interface.
        public void GetObjectData(SerializationInfo info, StreamingContext 
context)
                        {
                                // This method should never be called.
                                throw new NotSupportedException();
                        }

        // Implement the IObjectReference interface.
        [TODO]
        public Object GetRealObject(StreamingContext context)
                        {
                                // TODO
                                return null;
                        }

}; // class MemberInfoSerializationHolder

#endif // CONFIG_SERIALIZATION

}; // namespace System.Reflection

Index: ClrConstructor.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrConstructor.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ClrConstructor.cs   15 Apr 2003 11:22:32 -0000      1.5
--- ClrConstructor.cs   22 Aug 2003 03:04:07 -0000      1.6
***************
*** 29,34 ****
--- 29,38 ----
  using System.Globalization;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal sealed class ClrConstructor : ConstructorInfo, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
  
***************
*** 187,190 ****
--- 191,210 ----
                                return builder.ToString();
                        }
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this constructor.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               MemberInfoSerializationHolder.Serialize
+                                       (info, MemberTypes.Constructor,
+                                        Name, ToString(), ReflectedType);
+                       }
+ 
+ #endif
  
  }; // class ClrConstructor

Index: ClrEvent.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrEvent.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ClrEvent.cs 15 Apr 2003 11:22:32 -0000      1.5
--- ClrEvent.cs 22 Aug 2003 03:04:07 -0000      1.6
***************
*** 27,32 ****
--- 27,36 ----
  using System;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal sealed class ClrEvent : EventInfo, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
  
***************
*** 116,119 ****
--- 120,138 ----
                                                         nonPublic);
                        }
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this event.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               MemberInfoSerializationHolder.Serialize
+                                       (info, MemberTypes.Event, Name, 
ToString(), ReflectedType);
+                       }
+ 
+ #endif
  
  }; // class ClrEvent

Index: ClrField.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrField.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ClrField.cs 15 Apr 2003 11:22:32 -0000      1.6
--- ClrField.cs 22 Aug 2003 03:04:07 -0000      1.7
***************
*** 29,34 ****
--- 29,38 ----
  using System.Globalization;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal sealed class ClrField : FieldInfo, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
  
***************
*** 147,150 ****
--- 151,169 ----
                                return builder.ToString();
                        }
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this field.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               MemberInfoSerializationHolder.Serialize
+                                       (info, MemberTypes.Field, Name, 
ToString(), ReflectedType);
+                       }
+ 
+ #endif
  
  }; // class ClrField

Index: ClrMethod.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrMethod.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** ClrMethod.cs        8 Aug 2003 07:44:57 -0000       1.7
--- ClrMethod.cs        22 Aug 2003 03:04:07 -0000      1.8
***************
*** 29,34 ****
--- 29,38 ----
  using System.Text;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal sealed class ClrMethod : MethodInfo, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
  
***************
*** 277,280 ****
--- 281,299 ----
                                }
                        }
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this method.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               MemberInfoSerializationHolder.Serialize
+                                       (info, MemberTypes.Method, Name, 
ToString(), ReflectedType);
+                       }
+ 
+ #endif
  
  }; // class ClrMethod

Index: ClrProperty.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrProperty.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ClrProperty.cs      15 Apr 2003 11:22:32 -0000      1.5
--- ClrProperty.cs      22 Aug 2003 03:04:07 -0000      1.6
***************
*** 29,34 ****
--- 29,38 ----
  using System.Globalization;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal sealed class ClrProperty : PropertyInfo, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
  
***************
*** 294,297 ****
--- 298,316 ----
                                return builder.ToString();
                        }
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this property.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               MemberInfoSerializationHolder.Serialize
+                                       (info, MemberTypes.Property, Name, 
null, ReflectedType);
+                       }
+ 
+ #endif
  
  }; // class RuntimePropertyInfo

Index: ClrType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrType.cs,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** ClrType.cs  8 Aug 2003 07:08:45 -0000       1.19
--- ClrType.cs  22 Aug 2003 03:04:07 -0000      1.20
***************
*** 26,31 ****
--- 26,35 ----
  using System.Globalization;
  using System.Runtime.CompilerServices;
+ using System.Runtime.Serialization;
  
  internal class ClrType : Type, ICloneable, IClrProgramItem
+ #if CONFIG_SERIALIZATION
+       , ISerializable
+ #endif
  {
        // Internal state.
***************
*** 1043,1046 ****
--- 1047,1066 ----
  
  #endif // CONFIG_REFLECTION
+ 
+ #if CONFIG_SERIALIZATION
+ 
+       // Get the serialization data for this type.
+       public void GetObjectData(SerializationInfo info, StreamingContext 
context)
+                       {
+                               if(info == null)
+                               {
+                                       throw new ArgumentNullException("info");
+                               }
+                               UnitySerializationHolder.Serialize
+                                       (info, 
UnitySerializationHolder.UnityType.ClrType,
+                                        FullName, Assembly);
+                       }
+ 
+ #endif
  
  }; // class ClrType





reply via email to

[Prev in Thread] Current Thread [Next in Thread]