Ejemplo n.º 1
0
 internal ObjectHolder(object obj, long objID, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
 {
     this.m_object = obj;
     this.m_id = objID;
     this.m_flags = 0;
     this.m_missingElementsRemaining = 0;
     this.m_missingDecendents = 0;
     this.m_dependentObjects = null;
     this.m_next = null;
     this.m_serInfo = info;
     this.m_surrogate = surrogate;
     this.m_markForFixupWhenAvailable = false;
     if (obj is TypeLoadExceptionHolder)
     {
         this.m_typeLoad = (TypeLoadExceptionHolder) obj;
     }
     if ((idOfContainingObj != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
     {
         if (idOfContainingObj == objID)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
         }
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
     }
     this.SetFlags();
 }
Ejemplo n.º 2
0
 internal ObjectHolder(object obj, long objID, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
 {
     this.m_object = obj;
     this.m_id     = objID;
     this.m_flags  = 0;
     this.m_missingElementsRemaining = 0;
     this.m_missingDecendents        = 0;
     this.m_dependentObjects         = null;
     this.m_next      = null;
     this.m_serInfo   = info;
     this.m_surrogate = surrogate;
     this.m_markForFixupWhenAvailable = false;
     if (obj is TypeLoadExceptionHolder)
     {
         this.m_typeLoad = (TypeLoadExceptionHolder)obj;
     }
     if ((idOfContainingObj != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
     {
         if (idOfContainingObj == objID)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
         }
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
     }
     this.SetFlags();
 }
Ejemplo n.º 3
0
 internal void UpdateData(object obj, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainer, FieldInfo field, int[] arrayIndex, ObjectManager manager)
 {
     this.SetObjectValue(obj, manager);
     this.m_serInfo   = info;
     this.m_surrogate = surrogate;
     if ((idOfContainer != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
     {
         if (idOfContainer == this.m_id)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
         }
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainer, field, arrayIndex);
     }
     this.SetFlags();
     if (this.RequiresValueTypeFixup)
     {
         this.UpdateDescendentDependencyChain(this.m_missingElementsRemaining, manager);
     }
 }
Ejemplo n.º 4
0
 internal ObjectHolder(string obj, long objID, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
 {
     this.m_object = obj;
     this.m_id = objID;
     this.m_flags = 0;
     this.m_missingElementsRemaining = 0;
     this.m_missingDecendents = 0;
     this.m_dependentObjects = null;
     this.m_next = null;
     this.m_serInfo = info;
     this.m_surrogate = surrogate;
     this.m_markForFixupWhenAvailable = false;
     if ((idOfContainingObj != 0L) && (arrayIndex != null))
     {
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
     }
     if (this.m_valueFixup != null)
     {
         this.m_flags |= 8;
     }
 }
Ejemplo n.º 5
0
 internal ObjectHolder(string obj, long objID, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
 {
     this.m_object = obj;
     this.m_id     = objID;
     this.m_flags  = 0;
     this.m_missingElementsRemaining = 0;
     this.m_missingDecendents        = 0;
     this.m_dependentObjects         = null;
     this.m_next      = null;
     this.m_serInfo   = info;
     this.m_surrogate = surrogate;
     this.m_markForFixupWhenAvailable = false;
     if ((idOfContainingObj != 0L) && (arrayIndex != null))
     {
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
     }
     if (this.m_valueFixup != null)
     {
         this.m_flags |= 8;
     }
 }
Ejemplo n.º 6
0
 internal ObjectHolder(string obj, long objID, SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
 {
     this.m_object = (object)obj;
     this.m_id     = objID;
     this.m_flags  = 0;
     this.m_missingElementsRemaining = 0;
     this.m_missingDecendents        = 0;
     this.m_dependentObjects         = (LongList)null;
     this.m_next      = (ObjectHolder)null;
     this.m_serInfo   = info;
     this.m_surrogate = surrogate;
     this.m_markForFixupWhenAvailable = false;
     if (idOfContainingObj != 0L && arrayIndex != null)
     {
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
     }
     if (this.m_valueFixup == null)
     {
         return;
     }
     this.m_flags = this.m_flags | 8;
 }
Ejemplo n.º 7
0
        /*==================================UpdateData==================================
        **Action: Update the data in the object holder.  This should be called when the object
        **        is finally registered.  Presumably the ObjectHolder was created to track 
        **        some dependencies or preregistered fixups and we now need to actually record the
        **        object and other associated data.  We take this opportunity to set the flags
        **        so that we can do some faster processing in the future.
        **Returns: void
        **Arguments: obj -- The object being held by this object holder. (This should no longer be null).
        **           info --The SerializationInfo associated with this object, only required if we're doing delayed fixups.
        **           surrogate -- The surrogate handling this object.  May be null.
        **           idOfContainer -- The id of the object containing this one if this is a valuetype.
        **           member -- the MemberInfo of this object's position in it's container if this is a valuetype.
        **           manager -- the ObjectManager being used to track these ObjectHolders.
        **Exceptions: None. Asserts only.
        ==============================================================================*/
        internal virtual void UpdateData(Object obj, SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainer, FieldInfo field, int[] arrayIndex, ObjectManager manager) {
            BCLDebug.Assert(obj!=null,"obj!=null");
            BCLDebug.Assert(m_id>0,"m_id>0");
    
            //Record the fields that we can.
            SetObjectValue(obj, manager);
            m_serInfo = info;
            m_surrogate = surrogate;

            if (idOfContainer!=0 && ((field!=null && field.FieldType.IsValueType) || arrayIndex!=null)) {
                if (idOfContainer == m_id) {
                    throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
                }
                m_valueFixup = new ValueTypeFixupInfo(idOfContainer, field, arrayIndex);
            }

            SetFlags();
            
            if (RequiresValueTypeFixup) {
                UpdateDescendentDependencyChain(m_missingElementsRemaining, manager);
            }
        }
Ejemplo n.º 8
0
        internal ObjectHolder(String obj, long objID, SerializationInfo info, 
                              ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex) {
            BCLDebug.Assert(objID>=0,"objID>=0");
            
            m_object=obj; //May be null;
            m_id=objID;
    
            m_flags=0;
            m_missingElementsRemaining=0;
            m_missingDecendents = 0;
            m_dependentObjects=null;
            m_next=null;
            
            m_serInfo = info;
            m_surrogate = surrogate;
            m_markForFixupWhenAvailable = false;

            if (idOfContainingObj!=0 && arrayIndex!=null) {
                m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
            }

            if (m_valueFixup!=null) {
                m_flags|=REQUIRES_VALUETYPE_FIXUP;
            }
        }
Ejemplo n.º 9
0
        internal ObjectHolder(Object obj, long objID, SerializationInfo info, 
                              ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex) {
            BCLDebug.Assert(objID>=0,"objID>=0");
            
            m_object=obj; //May be null;
            m_id=objID;
    
            m_flags=0;
            m_missingElementsRemaining=0;
            m_missingDecendents = 0;
            m_dependentObjects=null;
            m_next=null;
            
            m_serInfo = info;
            m_surrogate = surrogate;
            m_markForFixupWhenAvailable = false;


            if (idOfContainingObj!=0 && ((field!=null && field.FieldType.IsValueType) || arrayIndex!=null)) {
                if (idOfContainingObj == objID) {
                    throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
                }

                m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
            }

            SetFlags();
        }
Ejemplo n.º 10
0
 internal void UpdateData(object obj, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainer, FieldInfo field, int[] arrayIndex, ObjectManager manager)
 {
     this.SetObjectValue(obj, manager);
     this.m_serInfo = info;
     this.m_surrogate = surrogate;
     if ((idOfContainer != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
     {
         if (idOfContainer == this.m_id)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
         }
         this.m_valueFixup = new ValueTypeFixupInfo(idOfContainer, field, arrayIndex);
     }
     this.SetFlags();
     if (this.RequiresValueTypeFixup)
     {
         this.UpdateDescendentDependencyChain(this.m_missingElementsRemaining, manager);
     }
 }
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] array = new FieldInfo[4];
            int         num   = 0;

            int[]  array2      = null;
            object objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if (num + 1 >= array.Length)
                {
                    FieldInfo[] array3 = new FieldInfo[array.Length * 2];
                    Array.Copy(array, array3, array.Length);
                    array = array3;
                }
                ValueTypeFixupInfo valueFixup = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != null)
                {
                    FieldInfo    parentField  = valueFixup.ParentField;
                    ObjectHolder objectHolder = this.FindObjectHolder(valueFixup.ContainerID);
                    if (objectHolder.ObjectValue == null)
                    {
                        break;
                    }
                    if (Nullable.GetUnderlyingType(parentField.FieldType) != null)
                    {
                        array[num] = parentField.FieldType.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);
                        num++;
                    }
                    array[num] = parentField;
                    holder     = objectHolder;
                    num++;
                }
                else
                {
                    holder = this.FindObjectHolder(valueFixup.ContainerID);
                    array2 = valueFixup.ParentIndex;
                    if (holder.ObjectValue == null)
                    {
                        break;
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && holder.ObjectValue != null)
            {
                objectValue = holder.ObjectValue;
            }
            if (num != 0)
            {
                FieldInfo[] array4 = new FieldInfo[num];
                for (int i = 0; i < num; i++)
                {
                    FieldInfo fieldInfo = array[num - 1 - i];
                    SerializationFieldInfo serializationFieldInfo = fieldInfo as SerializationFieldInfo;
                    array4[i] = ((serializationFieldInfo == null) ? fieldInfo : serializationFieldInfo.FieldInfo);
                }
                TypedReference typedReference = TypedReference.MakeTypedReference(objectValue, array4);
                if (memberToFix != null)
                {
                    ((RuntimeFieldInfo)memberToFix).SetValueDirect(typedReference, value);
                }
                else
                {
                    TypedReference.SetTypedReference(typedReference, value);
                }
            }
            else if (memberToFix != null)
            {
                FormatterServices.SerializationSetValue(memberToFix, objectValue, value);
            }
            if (array2 != null && holder.ObjectValue != null)
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, array2);
            }
            return(true);
        }
Ejemplo n.º 12
0
        internal ObjectHolder(
            object obj, long objID, SerializationInfo info, ISerializationSurrogate surrogate,
            long idOfContainingObj, FieldInfo field, int[] arrayIndex)
        {
            Debug.Assert(objID >= 0, "objID>=0");

            _object = obj; //May be null;
            _id = objID;

            _flags = 0;
            _missingElementsRemaining = 0;
            _missingDecendents = 0;
            _dependentObjects = null;
            _next = null;

            _serInfo = info;
            _surrogate = surrogate;
            _markForFixupWhenAvailable = false;

            if (obj is TypeLoadExceptionHolder)
            {
                _typeLoad = (TypeLoadExceptionHolder)obj;
            }

            if (idOfContainingObj != 0 && ((field != null && field.FieldType.IsValueType) || arrayIndex != null))
            {
                if (idOfContainingObj == objID)
                {
                    throw new SerializationException(SR.Serialization_ParentChildIdentical);
                }

                _valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
            }

            SetFlags();
        }
Ejemplo n.º 13
0
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] sourceArray = new FieldInfo[4];
            FieldInfo[] flds        = null;
            int         index       = 0;

            int[] indices = null;
            ValueTypeFixupInfo valueFixup  = null;
            object             objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if ((index + 1) >= sourceArray.Length)
                {
                    FieldInfo[] destinationArray = new FieldInfo[sourceArray.Length * 2];
                    Array.Copy(sourceArray, destinationArray, sourceArray.Length);
                    sourceArray = destinationArray;
                }
                valueFixup  = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != null)
                {
                    FieldInfo    parentField = valueFixup.ParentField;
                    ObjectHolder holder2     = this.FindObjectHolder(valueFixup.ContainerID);
                    if (holder2.ObjectValue == null)
                    {
                        break;
                    }
                    if (Nullable.GetUnderlyingType(parentField.FieldType) != null)
                    {
                        sourceArray[index] = parentField.FieldType.GetField("value", BindingFlags.NonPublic | BindingFlags.Instance);
                        index++;
                    }
                    sourceArray[index] = parentField;
                    holder             = holder2;
                    index++;
                }
                else
                {
                    holder  = this.FindObjectHolder(valueFixup.ContainerID);
                    indices = valueFixup.ParentIndex;
                    if (holder.ObjectValue != null)
                    {
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && (holder.ObjectValue != null))
            {
                objectValue = holder.ObjectValue;
            }
            if (index != 0)
            {
                flds = new FieldInfo[index];
                for (int i = 0; i < index; i++)
                {
                    FieldInfo info3 = sourceArray[(index - 1) - i];
                    SerializationFieldInfo info4 = info3 as SerializationFieldInfo;
                    flds[i] = (info4 == null) ? info3 : info4.FieldInfo;
                }
                TypedReference reference = TypedReference.MakeTypedReference(objectValue, flds);
                if (memberToFix != null)
                {
                    ((RuntimeFieldInfo)memberToFix).SetValueDirect(reference, value);
                }
                else
                {
                    TypedReference.SetTypedReference(reference, value);
                }
            }
            else if (memberToFix != null)
            {
                FormatterServices.SerializationSetValue(memberToFix, objectValue, value);
            }
            if ((indices != null) && (holder.ObjectValue != null))
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, indices);
            }
            return(true);
        }
Ejemplo n.º 14
0
        private bool DoValueTypeFixup(FieldInfo memberToFix, ObjectHolder holder, object value)
        {
            FieldInfo[] fieldInfoArray1 = new FieldInfo[4];
            int         length          = 0;

            int[]  numArray    = (int[])null;
            object objectValue = holder.ObjectValue;

            while (holder.RequiresValueTypeFixup)
            {
                if (length + 1 >= fieldInfoArray1.Length)
                {
                    FieldInfo[] fieldInfoArray2 = new FieldInfo[fieldInfoArray1.Length * 2];
                    Array.Copy((Array)fieldInfoArray1, (Array)fieldInfoArray2, fieldInfoArray1.Length);
                    fieldInfoArray1 = fieldInfoArray2;
                }
                ValueTypeFixupInfo valueFixup = holder.ValueFixup;
                objectValue = holder.ObjectValue;
                if (valueFixup.ParentField != (FieldInfo)null)
                {
                    FieldInfo    parentField  = valueFixup.ParentField;
                    ObjectHolder objectHolder = this.FindObjectHolder(valueFixup.ContainerID);
                    if (objectHolder.ObjectValue != null)
                    {
                        if (Nullable.GetUnderlyingType(parentField.FieldType) != (Type)null)
                        {
                            fieldInfoArray1[length] = parentField.FieldType.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic);
                            ++length;
                        }
                        fieldInfoArray1[length] = parentField;
                        holder = objectHolder;
                        ++length;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    holder   = this.FindObjectHolder(valueFixup.ContainerID);
                    numArray = valueFixup.ParentIndex;
                    if (holder.ObjectValue != null)
                    {
                        break;
                    }
                    break;
                }
            }
            if (!(holder.ObjectValue is Array) && holder.ObjectValue != null)
            {
                objectValue = holder.ObjectValue;
            }
            if (length != 0)
            {
                FieldInfo[] flds = new FieldInfo[length];
                for (int index = 0; index < length; ++index)
                {
                    FieldInfo fieldInfo = fieldInfoArray1[length - 1 - index];
                    SerializationFieldInfo serializationFieldInfo = fieldInfo as SerializationFieldInfo;
                    flds[index] = (FieldInfo)serializationFieldInfo == (FieldInfo)null ? fieldInfo : (FieldInfo)serializationFieldInfo.FieldInfo;
                }
                TypedReference target = TypedReference.MakeTypedReference(objectValue, flds);
                if (memberToFix != (FieldInfo)null)
                {
                    memberToFix.SetValueDirect(target, value);
                }
                else
                {
                    TypedReference.SetTypedReference(target, value);
                }
            }
            else if (memberToFix != (FieldInfo)null)
            {
                FormatterServices.SerializationSetValue((MemberInfo)memberToFix, objectValue, value);
            }
            if (numArray != null && holder.ObjectValue != null)
            {
                ((Array)holder.ObjectValue).SetValue(objectValue, numArray);
            }
            return(true);
        }