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/Runtime/Serialization


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Runtime/Serialization FormatterServices.cs,1.1,1.2 ObjectManager.cs,1.1,1.2
Date: Fri, 04 Apr 2003 22:48:45 -0500

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

Modified Files:
        FormatterServices.cs ObjectManager.cs 
Log Message:


Implement missing functionality in "System.Runtime.Serialization".


Index: FormatterServices.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Serialization/FormatterServices.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FormatterServices.cs        26 Jul 2002 04:26:45 -0000      1.1
--- FormatterServices.cs        5 Apr 2003 03:48:43 -0000       1.2
***************
*** 3,7 ****
   *                    "System.Runtime.Serialization.FormatterServices" class.
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,7 ----
   *                    "System.Runtime.Serialization.FormatterServices" class.
   *
!  * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 26,29 ****
--- 26,31 ----
  
  using System.Reflection;
+ using System.Security.Permissions;
+ using System.Runtime.CompilerServices;
  
  public sealed class FormatterServices
***************
*** 33,59 ****
  
        // Extract data from a specified object.
!       [TODO]
        public static Object[] GetObjectData(Object obj, MemberInfo[] members)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get all of the serializable members for a specified type.
!       [TODO]
        public static MemberInfo[] GetSerializableMembers(Type type)
                        {
!                               // TODO
!                               return null;
                        }
!       [TODO]
        public static MemberInfo[] GetSerializableMembers
                                (Type type, StreamingContext context)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get a named type from a specific assembly
        public static Type GetTypeFromAssembly(Assembly assem, String name)
                        {
--- 35,141 ----
  
        // Extract data from a specified object.
!       [SecurityPermission(SecurityAction.LinkDemand,
!                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
        public static Object[] GetObjectData(Object obj, MemberInfo[] members)
                        {
!                               if(obj == null)
!                               {
!                                       throw new ArgumentNullException("obj");
!                               }
!                               if(members == null)
!                               {
!                                       throw new 
ArgumentNullException("members");
!                               }
!                               Object[] data = new Object [members.Length];
!                               int index;
!                               for(index = 0; index < members.Length; ++index)
!                               {
!                                       if(members[index] == null)
!                                       {
!                                               throw new ArgumentNullException
!                                                       ("members[" + 
index.ToString() + "]");
!                                       }
!                                       if(!(members[index] is FieldInfo))
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_NotField"));
!                                       }
!                                       data[index] = 
((FieldInfo)(members[index])).GetValue(obj);
!                               }
!                               return data;
                        }
  
        // Get all of the serializable members for a specified type.
!       [SecurityPermission(SecurityAction.LinkDemand,
!                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
        public static MemberInfo[] GetSerializableMembers(Type type)
                        {
!                               return GetSerializableMembers
!                                       (type, new 
StreamingContext(StreamingContextStates.All));
                        }
!       [SecurityPermission(SecurityAction.LinkDemand,
!                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
        public static MemberInfo[] GetSerializableMembers
                                (Type type, StreamingContext context)
                        {
!                               if(type == null)
!                               {
!                                       throw new ArgumentNullException("type");
!                               }
! 
!                               // Fetch the property and field lists.
!                               FieldInfo[] fields = type.GetFields
!                                       (BindingFlags.Public | 
BindingFlags.NonPublic |
!                                        BindingFlags.Instance);
!                               PropertyInfo[] properties = type.GetProperties
!                                       (BindingFlags.Public | 
BindingFlags.NonPublic |
!                                        BindingFlags.Instance);
! 
!                               // Determine the size of the final array.
!                               int size = 0;
!                               int posn;
!                               for(posn = 0; posn < fields.Length; ++posn)
!                               {
!                                       if((fields[posn].Attributes &
!                                                       
FieldAttributes.NotSerialized) == 0)
!                                       {
!                                               ++size;
!                                       }
!                               }
!                               for(posn = 0; posn < properties.Length; ++posn)
!                               {
!                                       if(properties[posn].CanRead &&
!                                          properties[posn].CanWrite)
!                                       {
!                                               ++size;
!                                       }
!                               }
! 
!                               // Create the member array and populate it.
!                               MemberInfo[] members = new MemberInfo [size];
!                               size = 0;
!                               for(posn = 0; posn < fields.Length; ++posn)
!                               {
!                                       if((fields[posn].Attributes &
!                                                       
FieldAttributes.NotSerialized) == 0)
!                                       {
!                                               members[size++] = fields[posn];
!                                       }
!                               }
!                               for(posn = 0; posn < properties.Length; ++posn)
!                               {
!                                       if(properties[posn].CanRead &&
!                                          properties[posn].CanWrite)
!                                       {
!                                               members[size++] = 
properties[posn];
!                                       }
!                               }
!                               return members;
                        }
  
        // Get a named type from a specific assembly
+       [SecurityPermission(SecurityAction.LinkDemand,
+                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
+       [ReflectionPermission(SecurityAction.LinkDemand, TypeInformation=true)]
        public static Type GetTypeFromAssembly(Assembly assem, String name)
                        {
***************
*** 65,83 ****
                        }
  
        // Create a new unitialized instance of a specific object type.
!       [TODO]
!       public static Object GetUnitializedObject(Type type)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Populate the members of a specific object with given data values.
!       [TODO]
        public static Object PopulateObjectMembers
                                (Object obj, MemberInfo[] members, Object[] 
data)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 147,218 ----
                        }
  
+       // Get an uninitialized instance from the runtime engine.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static Object InternalGetUninitializedObject(Type type);
+ 
        // Create a new unitialized instance of a specific object type.
!       [SecurityPermission(SecurityAction.LinkDemand,
!                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
!       public static Object GetUninitializedObject(Type type)
                        {
!                               if(type == null)
!                               {
!                                       throw new ArgumentNullException("type");
!                               }
!                               else if(!(type is ClrType))
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_NotClrType"));
!                               }
!                               return InternalGetUninitializedObject(type);
                        }
  
        // Populate the members of a specific object with given data values.
!       [SecurityPermission(SecurityAction.LinkDemand,
!                                               
Flags=SecurityPermissionFlag.SerializationFormatter)]
        public static Object PopulateObjectMembers
                                (Object obj, MemberInfo[] members, Object[] 
data)
                        {
!                               // Validate the parameters.
!                               if(obj == null)
!                               {
!                                       throw new ArgumentNullException("obj");
!                               }
!                               else if(members == null)
!                               {
!                                       throw new 
ArgumentNullException("members");
!                               }
!                               else if(data == null)
!                               {
!                                       throw new ArgumentNullException("data");
!                               }
!                               else if(members.Length != data.Length)
!                               {
!                                       throw new ArgumentException
!                                               
(_("Serialize_MemberDataMismatch"));
!                               }
! 
!                               // Set the member values.
!                               int index;
!                               for(index = 0; index < members.Length; ++index)
!                               {
!                                       if(members[index] == null)
!                                       {
!                                               throw new ArgumentNullException
!                                                       ("members[" + 
index.ToString() + "]");
!                                       }
!                                       if(data[index] == null)
!                                       {
!                                               // Skip entries with null 
values.
!                                               continue;
!                                       }
!                                       if(!(members[index] is FieldInfo))
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_NotField"));
!                                       }
!                                       
((FieldInfo)(members[index])).SetValue(obj, data[index]);
!                               }
!                               return obj;
                        }
  

Index: ObjectManager.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Serialization/ObjectManager.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ObjectManager.cs    26 Jul 2002 04:26:45 -0000      1.1
--- ObjectManager.cs    5 Apr 2003 03:48:43 -0000       1.2
***************
*** 3,7 ****
   *                    "System.Runtime.Serialization.ObjectManager" class.
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,7 ----
   *                    "System.Runtime.Serialization.ObjectManager" class.
   *
!  * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 25,102 ****
  #if !ECMA_COMPAT
  
  using System.Reflection;
  
  public class ObjectManager
  {
  
        // Constructor.
-       [TODO]
        public ObjectManager(ISurrogateSelector selector,
                                                 StreamingContext context)
                        {
!                               // TODO
                        }
  
        // Perform recorded fixups.
-       [TODO]
        public virtual void DoFixups()
                        {
!                               // TODO
                        }
  
        // Return an object with a specific identifier.
-       [TODO]
        public virtual Object GetObject(long objectID)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Raise a deserialization event on all register objects that want it.
!       [TODO]
!       public virtual void RaiseDeseralizationEvent()
                        {
!                               // TODO
                        }
  
        // Record an array element fixup to be performed later.
-       [TODO]
        public virtual void RecordArrayElementFixup
                                (long arrayToBeFixed, int index, long 
objectRequired)
                        {
!                               // TODO
                        }
        public virtual void RecordArrayElementFixup
                                (long arrayToBeFixed, int[] indices, long 
objectRequired)
                        {
!                               // TODO
                        }
  
        // Record an object member fixup to be performed later.
-       [TODO]
        public virtual void RecordDelayedFixup
                                (long objectToBeFixed, String memberName, long 
objectRequired)
                        {
!                               // TODO
                        }
        public virtual void RecordFixup
                                (long objectToBeFixed, MemberInfo member, long 
objectRequired)
                        {
!                               // TODO
                        }
  
        // Register an object with the object manager.
-       [TODO]
        public virtual void RegisterObject(Object obj, long objectID)
                        {
!                               // TODO
                        }
-       [TODO]
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info)
                        {
!                               // TODO
                        }
-       [TODO]
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info,
--- 25,385 ----
  #if !ECMA_COMPAT
  
+ using System.Collections;
  using System.Reflection;
+ using System.Security.Permissions;
  
  public class ObjectManager
  {
+       // Information that is stored for a member fixup.
+       private sealed class ObjectFixup
+       {
+               public ObjectInfo obj;
+               public MemberInfo member;
+               public String memberName;
+               public int[] arrayIndex;
+               public ObjectFixup nextFixup;
+ 
+       }; // class ObjectFixup
+ 
+       // Information that is stored for an object identifier.
+       private sealed class ObjectInfo
+       {
+               public Object obj;
+               public SerializationInfo sinfo;
+               public long idOfContainingObject;
+               public MemberInfo member;
+               public int[] arrayIndex;
+               public ObjectInfo contains;
+               public ObjectInfo nextContains;
+               public ObjectFixup fixups;
+               public bool done;
+ 
+       }; // class ObjectInfo
+ 
+       // Internal state.
+       private ISurrogateSelector selector;
+       private StreamingContext context;
+       private Hashtable objects;
+       private ArrayList callbackList;
  
        // Constructor.
        public ObjectManager(ISurrogateSelector selector,
                                                 StreamingContext context)
                        {
!                               // Make sure that we have the correct 
permissions.
!                               SecurityPermission perm = new SecurityPermission
!                                       
(SecurityPermissionFlag.SerializationFormatter);
!                               perm.Demand();
! 
!                               // Initialize the object manager.
!                               this.selector = selector;
!                               this.context = context;
!                               this.objects = new Hashtable();
!                               this.callbackList = new ArrayList();
!                       }
! 
!       // Apply a fixup.
!       private static void ApplyFixup(ObjectInfo oinfo, ObjectFixup fixup)
!                       {
!                               if(fixup.obj.obj == null)
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_MissingFixup"));
!                               }
!                               if(fixup.member != null)
!                               {
!                                       if(fixup.member is FieldInfo)
!                                       {
!                                               
((FieldInfo)(fixup.member)).SetValue
!                                                       (oinfo.obj, 
fixup.obj.obj);
!                                       }
!                                       else
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_BadFixup"));
!                                       }
!                               }
!                               else if(fixup.memberName != null)
!                               {
!                                       MemberInfo[] member = 
oinfo.obj.GetType().GetMember
!                                               (fixup.memberName);
!                                       if(member == null || member.Length != 1)
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_BadFixup"));
!                                       }
!                                       if(member[0] is FieldInfo)
!                                       {
!                                               
((FieldInfo)(member[0])).SetValue
!                                                       (oinfo.obj, 
fixup.obj.obj);
!                                       }
!                                       else
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_BadFixup"));
!                                       }
!                               }
!                               else if(fixup.arrayIndex != null)
!                               {
!                                       ((Array)(oinfo.obj)).SetValue
!                                               (fixup.obj.obj, 
fixup.arrayIndex);
!                               }
!                               else
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_BadFixup"));
!                               }
!                       }
! 
!       // Apply a contained member fixup.
!       private static void ApplyContained(ObjectInfo oinfo, ObjectInfo contain)
!                       {
!                               if(contain.member != null)
!                               {
!                                       if(contain.member is FieldInfo)
!                                       {
!                                               
((FieldInfo)(contain.member)).SetValue
!                                                       (oinfo.obj, 
contain.obj);
!                                       }
!                                       else
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_BadFixup"));
!                                       }
!                               }
!                               else if(contain.arrayIndex != null)
!                               {
!                                       ((Array)(oinfo.obj)).SetValue
!                                               (contain.obj, 
contain.arrayIndex);
!                               }
!                               else
!                               {
!                                       throw new SerializationException
!                                               (_("Serialize_BadFixup"));
!                               }
!                       }
! 
!       // Perform recorded fixups for contained objects.
!       private static void DoFixupsForContained(ObjectInfo oinfo)
!                       {
!                               ObjectInfo contain = oinfo.contains;
!                               ObjectFixup fixup;
!                               do
!                               {
!                                       if(!(contain.done))
!                                       {
!                                               contain.done = true;
!                                               if(contain.obj == null)
!                                               {
!                                                       throw new 
SerializationException
!                                                               
(_("Serialize_MissingFixup"));
!                                               }
!                                               if(contain.contains != null)
!                                               {
!                                                       
DoFixupsForContained(contain);
!                                               }
!                                               fixup = contain.fixups;
!                                               while(fixup != null)
!                                               {
!                                                       ApplyFixup(contain, 
fixup);
!                                                       fixup = fixup.nextFixup;
!                                               }
!                                               ApplyContained(oinfo, contain);
!                                       }
!                                       contain = contain.nextContains;
!                               }
!                               while(contain != null);
                        }
  
        // Perform recorded fixups.
        public virtual void DoFixups()
                        {
!                               IDictionaryEnumerator e = 
objects.GetEnumerator();
!                               ObjectInfo oinfo;
!                               ObjectFixup fixup;
!                               while(e.MoveNext())
!                               {
!                                       oinfo = (ObjectInfo)(e.Value);
!                                       if(oinfo.obj == null)
!                                       {
!                                               throw new SerializationException
!                                                       
(_("Serialize_MissingFixup"));
!                                       }
!                                       if(oinfo.done || 
oinfo.idOfContainingObject > 0)
!                                       {
!                                               // We already saw this object 
or the object is
!                                               // contained within something 
at a higher level.
!                                               continue;
!                                       }
!                                       oinfo.done = true;
!                                       if(oinfo.contains != null)
!                                       {
!                                               // Handle value type members 
within this object.
!                                               DoFixupsForContained(oinfo);
!                                       }
!                                       fixup = oinfo.fixups;
!                                       while(fixup != null)
!                                       {
!                                               ApplyFixup(oinfo, fixup);
!                                               fixup = fixup.nextFixup;
!                                       }
!                               }
                        }
  
        // Return an object with a specific identifier.
        public virtual Object GetObject(long objectID)
                        {
!                               if(objectID <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectID", 
_("Serialize_BadObjectID"));
!                               }
!                               ObjectInfo info = 
(ObjectInfo)(objects[objectID]);
!                               if(info != null)
!                               {
!                                       return info.obj;
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Raise a deserialization event on all register objects that want it.
!       public virtual void RaiseDeserializationEvent()
                        {
!                               IEnumerator e = callbackList.GetEnumerator();
!                               while(e.MoveNext())
!                               {
!                                       IDeserializationCallback cb;
!                                       cb = (e.Current as 
IDeserializationCallback);
!                                       if(cb != null)
!                                       {
!                                               cb.OnDeserialization(null);
!                                       }
!                               }
!                       }
! 
!       // Record a fixup.
!       private void RecordFixup(long objectToBeFixed, long objectRequired,
!                                                        MemberInfo member, 
String memberName,
!                                                        int[] arrayIndex)
!                       {
!                               // Find or create the containing object's 
information block.
!                               ObjectInfo oinfo = 
(ObjectInfo)(objects[objectToBeFixed]);
!                               if(oinfo == null)
!                               {
!                                       oinfo = new ObjectInfo();
!                                       objects[objectToBeFixed] = oinfo;
!                               }
! 
!                               // Find or create the required object's 
information block.
!                               ObjectInfo oinfo2 = 
(ObjectInfo)(objects[objectRequired]);
!                               if(oinfo2 == null)
!                               {
!                                       oinfo2 = new ObjectInfo();
!                                       objects[objectRequired] = oinfo2;
!                               }
! 
!                               // Add a fixup to the containing object.
!                               ObjectFixup fixup = new ObjectFixup();
!                               fixup.obj = oinfo2;
!                               fixup.member = member;
!                               fixup.memberName = memberName;
!                               fixup.arrayIndex = arrayIndex;
!                               fixup.nextFixup = oinfo.fixups;
!                               oinfo.fixups = fixup;
                        }
  
        // Record an array element fixup to be performed later.
        public virtual void RecordArrayElementFixup
                                (long arrayToBeFixed, int index, long 
objectRequired)
                        {
!                               if(arrayToBeFixed <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("arrayToBeFixed", 
_("Serialize_BadObjectID"));
!                               }
!                               if(objectRequired <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectRequired", 
_("Serialize_BadObjectID"));
!                               }
!                               RecordFixup(arrayToBeFixed, objectRequired,
!                                                       null, null, new int[] 
{index});
                        }
        public virtual void RecordArrayElementFixup
                                (long arrayToBeFixed, int[] indices, long 
objectRequired)
                        {
!                               if(arrayToBeFixed <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("arrayToBeFixed", 
_("Serialize_BadObjectID"));
!                               }
!                               if(objectRequired <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectRequired", 
_("Serialize_BadObjectID"));
!                               }
!                               if(indices == null)
!                               {
!                                       throw new 
ArgumentNullException("indices");
!                               }
!                               RecordFixup(arrayToBeFixed, objectRequired,
!                                                       null, null, indices);
                        }
  
        // Record an object member fixup to be performed later.
        public virtual void RecordDelayedFixup
                                (long objectToBeFixed, String memberName, long 
objectRequired)
                        {
!                               if(objectToBeFixed <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectToBeFixed", 
_("Serialize_BadObjectID"));
!                               }
!                               if(objectRequired <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectRequired", 
_("Serialize_BadObjectID"));
!                               }
!                               if(memberName == null)
!                               {
!                                       throw new 
ArgumentNullException("memberName");
!                               }
!                               RecordFixup(objectToBeFixed, objectRequired,
!                                                       null, memberName, null);
                        }
        public virtual void RecordFixup
                                (long objectToBeFixed, MemberInfo member, long 
objectRequired)
                        {
!                               if(objectToBeFixed <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectToBeFixed", 
_("Serialize_BadObjectID"));
!                               }
!                               if(objectRequired <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectRequired", 
_("Serialize_BadObjectID"));
!                               }
!                               if(member == null)
!                               {
!                                       throw new 
ArgumentNullException("member");
!                               }
!                               RecordFixup(objectToBeFixed, objectRequired,
!                                                       member, null, null);
                        }
  
        // Register an object with the object manager.
        public virtual void RegisterObject(Object obj, long objectID)
                        {
!                               RegisterObject(obj, objectID, null, 0, null, 
null);
                        }
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info)
                        {
!                               RegisterObject(obj, objectID, info, 0, null, 
null);
                        }
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info,
***************
*** 104,110 ****
                                                           MemberInfo member)
                        {
!                               // TODO
                        }
-       [TODO]
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info,
--- 387,393 ----
                                                           MemberInfo member)
                        {
!                               RegisterObject(obj, objectID, info, 
idOfContainingObj,
!                                                          member, null);
                        }
        public void RegisterObject(Object obj, long objectID,
                                                           SerializationInfo 
info,
***************
*** 113,117 ****
                                                           int[] arrayIndex)
                        {
!                               // TODO
                        }
  
--- 396,475 ----
                                                           int[] arrayIndex)
                        {
!                               if(obj == null)
!                               {
!                                       throw new 
ArgumentNullException("objectID");
!                               }
!                               if(objectID <= 0)
!                               {
!                                       throw new ArgumentOutOfRangeException
!                                               ("objectID", 
_("Serialize_BadObjectID"));
!                               }
!                               ObjectInfo oinfo = 
(ObjectInfo)(objects[objectID]);
!                               if(oinfo != null && oinfo.obj != obj)
!                               {
!                                       throw new SerializationException
!                                               
(_("Serialize_AlreadyRegistered"));
!                               }
!                               else if(oinfo != null)
!                               {
!                                       // Update the information for an 
existing reference.
!                                       oinfo.obj = obj;
!                                       if(info != null)
!                                       {
!                                               oinfo.sinfo = info;
!                                       }
!                                       if(member != null)
!                                       {
!                                               oinfo.member = member;
!                                       }
!                                       if(arrayIndex != null)
!                                       {
!                                               oinfo.arrayIndex = arrayIndex;
!                                       }
!                                       if(idOfContainingObj != 0 &&
!                                          oinfo.idOfContainingObject == 0)
!                                       {
!                                               oinfo.idOfContainingObject = 
idOfContainingObj;
!                                               RegisterWithContaining(oinfo);
!                                       }
!                               }
!                               else
!                               {
!                                       // Create a new object information 
block.
!                                       oinfo = new ObjectInfo();
!                                       oinfo.obj = obj;
!                                       oinfo.sinfo = info;
!                                       oinfo.idOfContainingObject = 
idOfContainingObj;
!                                       oinfo.member = member;
!                                       oinfo.arrayIndex = arrayIndex;
!                                       objects[objectID] = oinfo;
! 
!                                       // Register the object to be called 
later by
!                                       // "RaiseDeserializationEvent".
!                                       if(obj is IDeserializationCallback)
!                                       {
!                                               callbackList.Add(obj);
!                                       }
! 
!                                       // Register the information block with 
the container.
!                                       if(idOfContainingObj > 0)
!                                       {
!                                               RegisterWithContaining(oinfo);
!                                       }
!                               }
!                       }
! 
!       // Register an object with its containing object.
!       private void RegisterWithContaining(ObjectInfo oinfo)
!                       {
!                               ObjectInfo oinfo2 =
!                                       
(ObjectInfo)(objects[oinfo.idOfContainingObject]);
!                               if(oinfo2 == null)
!                               {
!                                       oinfo2 = new ObjectInfo();
!                                       objects[oinfo.idOfContainingObject] = 
oinfo2;
!                               }
!                               oinfo.nextContains = oinfo2.contains;
!                               oinfo2.contains = oinfo;
                        }
  





reply via email to

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