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 RuntimeFieldHandle.cs,


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System RuntimeFieldHandle.cs, 1.8, 1.9 RuntimeMethodHandle.cs, 1.9, 1.10 RuntimeTypeHandle.cs, 1.8, 1.9 UnitySerializationHolder.cs, 1.1, 1.2
Date: Thu, 21 Aug 2003 23:04:09 -0400

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

Modified Files:
        RuntimeFieldHandle.cs RuntimeMethodHandle.cs 
        RuntimeTypeHandle.cs UnitySerializationHolder.cs 
Log Message:


Serialization support for reflection classes.


Index: RuntimeFieldHandle.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/RuntimeFieldHandle.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** RuntimeFieldHandle.cs       26 May 2003 04:41:21 -0000      1.8
--- RuntimeFieldHandle.cs       22 Aug 2003 03:04:07 -0000      1.9
***************
*** 23,26 ****
--- 23,27 ----
  {
  
+ using System.Reflection;
  using System.Runtime.Serialization;
  
***************
*** 51,68 ****
  
        // De-serialize this object.
-       [TODO]
        internal RuntimeFieldHandle(SerializationInfo info,
                                                                
StreamingContext context)
                        {
!                               // TODO
!                               value_ = IntPtr.Zero;
                        }
  
        // Get the serialization data for this object.
-       [TODO]
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               // TODO
                        }
  
--- 52,87 ----
  
        // De-serialize this object.
        internal RuntimeFieldHandle(SerializationInfo info,
                                                                
StreamingContext context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               FieldInfo field = (FieldInfo)(info.GetValue
!                                       ("FieldObj", typeof(ClrField)));
!                               if(field == null)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               value_ = field.FieldHandle.value_;
                        }
  
        // Get the serialization data for this object.
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               if(value_ == IntPtr.Zero)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               ClrField field = 
(ClrField)(FieldInfo.GetFieldFromHandle(this));
!                               info.AddValue("FieldObj", field, 
typeof(ClrField));
                        }
  

Index: RuntimeMethodHandle.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/RuntimeMethodHandle.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** RuntimeMethodHandle.cs      26 May 2003 04:41:21 -0000      1.9
--- RuntimeMethodHandle.cs      22 Aug 2003 03:04:07 -0000      1.10
***************
*** 25,28 ****
--- 25,29 ----
  #if CONFIG_RUNTIME_INFRA
  
+ using System.Reflection;
  using System.Runtime.CompilerServices;
  using System.Runtime.Serialization;
***************
*** 60,77 ****
  
        // De-serialize this object.
-       [TODO]
        internal RuntimeMethodHandle(SerializationInfo info,
                                                                 
StreamingContext context)
                        {
!                               // TODO
!                               value_ = IntPtr.Zero;
                        }
  
        // Get the serialization data for this object.
-       [TODO]
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               // TODO
                        }
  
--- 61,113 ----
  
        // De-serialize this object.
        internal RuntimeMethodHandle(SerializationInfo info,
                                                                 
StreamingContext context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               MethodBase method = (MethodBase)(info.GetValue
!                                       ("MethodObj", typeof(ClrMethod)));
!                               if(method == null)
!                               {
!                                       // Extension: check for constructors as 
well.
!                                       method = (MethodBase)(info.GetValue
!                                               ("ConstructorObj", 
typeof(ClrConstructor)));
!                               }
!                               if(method == null)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               value_ = method.MethodHandle.value_;
                        }
  
        // Get the serialization data for this object.
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               if(value_ == IntPtr.Zero)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               MethodBase method = (MethodBase)
!                                       (MethodBase.GetMethodFromHandle(this));
!                               if(method is ClrConstructor)
!                               {
!                                       // Extension: properly serialize 
constructor handles.
!                                       info.AddValue("MethodObj", null, 
typeof(ClrMethod));
!                                       info.AddValue("ConstructorObj", method,
!                                                                 
typeof(ClrConstructor));
!                               }
!                               else
!                               {
!                                       info.AddValue("MethodObj", method, 
typeof(ClrMethod));
!                               }
                        }
  

Index: RuntimeTypeHandle.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/RuntimeTypeHandle.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** RuntimeTypeHandle.cs        26 May 2003 04:41:21 -0000      1.8
--- RuntimeTypeHandle.cs        22 Aug 2003 03:04:07 -0000      1.9
***************
*** 22,25 ****
--- 22,26 ----
  {
  
+ using System.Reflection;
  using System.Runtime.Serialization;
  
***************
*** 50,67 ****
  
        // De-serialize this object.
-       [TODO]
        internal RuntimeTypeHandle(SerializationInfo info,
                                                           StreamingContext 
context)
                        {
!                               // TODO
!                               value_ = IntPtr.Zero;
                        }
  
        // Get the serialization data for this object.
-       [TODO]
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               // TODO
                        }
  
--- 51,85 ----
  
        // De-serialize this object.
        internal RuntimeTypeHandle(SerializationInfo info,
                                                           StreamingContext 
context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               Type t = (Type)(info.GetValue("TypeObj", 
typeof(ClrType)));
!                               if(t == null)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               value_ = t.TypeHandle.value_;
                        }
  
        // Get the serialization data for this object.
        public void GetObjectData(SerializationInfo info,
                                                          StreamingContext 
context)
                        {
!                               if(info == null)
!                               {
!                                       throw new ArgumentNullException("info");
!                               }
!                               if(value_ == IntPtr.Zero)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_StateMissing"));
!                               }
!                               ClrType type = 
(ClrType)(Type.GetTypeFromHandle(this));
!                               info.AddValue("TypeObj", type, typeof(ClrType));
                        }
  

Index: UnitySerializationHolder.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/UnitySerializationHolder.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** UnitySerializationHolder.cs 20 Aug 2003 02:44:47 -0000      1.1
--- UnitySerializationHolder.cs 22 Aug 2003 03:04:07 -0000      1.2
***************
*** 101,104 ****
--- 101,127 ----
                                        case UnityType.Missing:         return 
Missing.Value;
  
+                                       case UnityType.ClrType:
+                                       {
+                                               if(data == null || data.Length 
== 0 ||
+                                                  assembly == null)
+                                               {
+                                                       throw new 
SerializationException
+                                                               
(_("Serialize_StateMissing"));
+                                               }
+                                               if(assembly == String.Empty)
+                                               {
+                                                       return 
Type.GetType(data);
+                                               }
+                                               Type type = 
FormatterServices.GetTypeFromAssembly
+                                                       (assembly, data);
+                                               if(type != null)
+                                               {
+                                                       return type;
+                                               }
+                                               throw new SerializationException
+                                                       
(_("Serialize_StateMissing"));
+                                       }
+                                       // Not reached.
+ 
                                        // TODO: other unity types
  





reply via email to

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