Example #1
0
 internal void AddFixup(FixupHolder fixup, ObjectManager manager)
 {
     if (this.m_missingElements == null)
     {
         this.m_missingElements = new FixupHolderList();
     }
     this.m_missingElements.Add(fixup);
     this.m_missingElementsRemaining++;
     if (this.RequiresValueTypeFixup)
     {
         this.UpdateDescendentDependencyChain(1, manager);
     }
 }
Example #2
0
 /*===================================AddFixup===================================
 **Action: Note a fixup that has to be done before this object can be completed.
 **        Fixups are things that need to happen when other objects in the graph 
 **        are added.  Dependencies are things that need to happen when this object
 **        is added.
 **Returns: void
 **Arguments: fixup -- The fixup holder containing enough information to complete the fixup.
 **Exceptions: None.
 ==============================================================================*/
 internal virtual void AddFixup(FixupHolder fixup, ObjectManager manager) {
     if (m_missingElements==null) {
         m_missingElements = new FixupHolderList();
     }
     m_missingElements.Add(fixup);
     m_missingElementsRemaining++;
     
     if (RequiresValueTypeFixup) {
         UpdateDescendentDependencyChain(1, manager);
     }
 }
        internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete)
        {
            FixupHolderList missingElements = holder.m_missingElements;
            object          obj             = null;
            ObjectHolder    objectHolder    = null;
            int             num             = 0;

            if (holder.ObjectValue == null)
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissingObject", new object[]
                {
                    holder.m_id
                }));
            }
            if (missingElements == null)
            {
                return;
            }
            if (holder.HasSurrogate || holder.HasISerializable)
            {
                SerializationInfo serInfo = holder.m_serInfo;
                if (serInfo == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidFixupDiscovered"));
                }
                if (missingElements != null)
                {
                    for (int i = 0; i < missingElements.m_count; i++)
                    {
                        if (missingElements.m_values[i] != null && this.GetCompletionInfo(missingElements.m_values[i], out objectHolder, out obj, bObjectFullyComplete))
                        {
                            object objectValue = objectHolder.ObjectValue;
                            if (this.CanCallGetType(objectValue))
                            {
                                serInfo.UpdateValue((string)obj, objectValue, objectValue.GetType());
                            }
                            else
                            {
                                serInfo.UpdateValue((string)obj, objectValue, typeof(MarshalByRefObject));
                            }
                            num++;
                            missingElements.m_values[i] = null;
                            if (!bObjectFullyComplete)
                            {
                                holder.DecrementFixupsRemaining(this);
                                objectHolder.RemoveDependency(holder.m_id);
                            }
                        }
                    }
                }
            }
            else
            {
                for (int j = 0; j < missingElements.m_count; j++)
                {
                    FixupHolder fixupHolder = missingElements.m_values[j];
                    if (fixupHolder != null && this.GetCompletionInfo(fixupHolder, out objectHolder, out obj, bObjectFullyComplete))
                    {
                        if (objectHolder.TypeLoadExceptionReachable)
                        {
                            holder.TypeLoadException = objectHolder.TypeLoadException;
                            if (holder.Reachable)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_TypeLoadFailure", new object[]
                                {
                                    holder.TypeLoadException.TypeName
                                }));
                            }
                        }
                        if (holder.Reachable)
                        {
                            objectHolder.Reachable = true;
                        }
                        int fixupType = fixupHolder.m_fixupType;
                        if (fixupType != 1)
                        {
                            if (fixupType != 2)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                            }
                            MemberInfo memberInfo = (MemberInfo)obj;
                            if (memberInfo.MemberType != MemberTypes.Field)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                            }
                            if (holder.RequiresValueTypeFixup && holder.ValueTypeFixupPerformed)
                            {
                                if (!this.DoValueTypeFixup((FieldInfo)memberInfo, holder, objectHolder.ObjectValue))
                                {
                                    throw new SerializationException(Environment.GetResourceString("Serialization_PartialValueTypeFixup"));
                                }
                            }
                            else
                            {
                                FormatterServices.SerializationSetValue(memberInfo, holder.ObjectValue, objectHolder.ObjectValue);
                            }
                            if (objectHolder.RequiresValueTypeFixup)
                            {
                                objectHolder.ValueTypeFixupPerformed = true;
                            }
                        }
                        else
                        {
                            if (holder.RequiresValueTypeFixup)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_ValueTypeFixup"));
                            }
                            ((Array)holder.ObjectValue).SetValue(objectHolder.ObjectValue, (int[])obj);
                        }
                        num++;
                        missingElements.m_values[j] = null;
                        if (!bObjectFullyComplete)
                        {
                            holder.DecrementFixupsRemaining(this);
                            objectHolder.RemoveDependency(holder.m_id);
                        }
                    }
                }
            }
            this.m_fixupCount -= (long)num;
            if (missingElements.m_count == num)
            {
                holder.m_missingElements = null;
            }
        }
Example #4
0
        internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete)
        {
            FixupHolderList missingElements = holder.m_missingElements;
            object          member          = null;
            ObjectHolder    holder3         = null;
            int             num             = 0;

            if (holder.ObjectValue == null)
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissingObject", new object[] { holder.m_id }));
            }
            if (missingElements != null)
            {
                if (holder.HasSurrogate || holder.HasISerializable)
                {
                    SerializationInfo serInfo = holder.m_serInfo;
                    if (serInfo == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InvalidFixupDiscovered"));
                    }
                    if (missingElements != null)
                    {
                        for (int i = 0; i < missingElements.m_count; i++)
                        {
                            if ((missingElements.m_values[i] != null) && this.GetCompletionInfo(missingElements.m_values[i], out holder3, out member, bObjectFullyComplete))
                            {
                                object objectValue = holder3.ObjectValue;
                                if (this.CanCallGetType(objectValue))
                                {
                                    serInfo.UpdateValue((string)member, objectValue, objectValue.GetType());
                                }
                                else
                                {
                                    serInfo.UpdateValue((string)member, objectValue, typeof(MarshalByRefObject));
                                }
                                num++;
                                missingElements.m_values[i] = null;
                                if (!bObjectFullyComplete)
                                {
                                    holder.DecrementFixupsRemaining(this);
                                    holder3.RemoveDependency(holder.m_id);
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < missingElements.m_count; j++)
                    {
                        MemberInfo  info2;
                        FixupHolder fixup = missingElements.m_values[j];
                        if ((fixup == null) || !this.GetCompletionInfo(fixup, out holder3, out member, bObjectFullyComplete))
                        {
                            continue;
                        }
                        if (holder3.TypeLoadExceptionReachable)
                        {
                            holder.TypeLoadException = holder3.TypeLoadException;
                            if (holder.Reachable)
                            {
                                throw new SerializationException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_TypeLoadFailure"), new object[] { holder.TypeLoadException.TypeName }));
                            }
                        }
                        if (holder.Reachable)
                        {
                            holder3.Reachable = true;
                        }
                        switch (fixup.m_fixupType)
                        {
                        case 1:
                            if (holder.RequiresValueTypeFixup)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_ValueTypeFixup"));
                            }
                            break;

                        case 2:
                            info2 = (MemberInfo)member;
                            if (info2.MemberType != MemberTypes.Field)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                            }
                            if (!holder.RequiresValueTypeFixup || !holder.ValueTypeFixupPerformed)
                            {
                                goto Label_024C;
                            }
                            if (!this.DoValueTypeFixup((FieldInfo)info2, holder, holder3.ObjectValue))
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_PartialValueTypeFixup"));
                            }
                            goto Label_0260;

                        default:
                            throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                        }
                        ((Array)holder.ObjectValue).SetValue(holder3.ObjectValue, (int[])member);
                        goto Label_0293;
Label_024C:
                        FormatterServices.SerializationSetValue(info2, holder.ObjectValue, holder3.ObjectValue);
Label_0260:
                        if (holder3.RequiresValueTypeFixup)
                        {
                            holder3.ValueTypeFixupPerformed = true;
                        }
Label_0293:
                        num++;
                        missingElements.m_values[j] = null;
                        if (!bObjectFullyComplete)
                        {
                            holder.DecrementFixupsRemaining(this);
                            holder3.RemoveDependency(holder.m_id);
                        }
                    }
                }
                this.m_fixupCount -= num;
                if (missingElements.m_count == num)
                {
                    holder.m_missingElements = null;
                }
            }
        }
Example #5
0
        internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete)
        {
            FixupHolderList fixupHolderList = holder.m_missingElements;
            object          member          = (object)null;
            ObjectHolder    holder1         = (ObjectHolder)null;
            int             num             = 0;

            if (holder.ObjectValue == null)
            {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissingObject", (object)holder.m_id));
            }
            if (fixupHolderList == null)
            {
                return;
            }
            if (holder.HasSurrogate || holder.HasISerializable)
            {
                SerializationInfo serializationInfo1 = holder.m_serInfo;
                if (serializationInfo1 == null)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidFixupDiscovered"));
                }
                if (fixupHolderList != null)
                {
                    for (int index = 0; index < fixupHolderList.m_count; ++index)
                    {
                        if (fixupHolderList.m_values[index] != null && this.GetCompletionInfo(fixupHolderList.m_values[index], out holder1, out member, bObjectFullyComplete))
                        {
                            object objectValue = holder1.ObjectValue;
                            if (this.CanCallGetType(objectValue))
                            {
                                SerializationInfo serializationInfo2 = serializationInfo1;
                                string            name = (string)member;
                                object            obj  = objectValue;
                                Type type = obj.GetType();
                                serializationInfo2.UpdateValue(name, obj, type);
                            }
                            else
                            {
                                serializationInfo1.UpdateValue((string)member, objectValue, typeof(MarshalByRefObject));
                            }
                            ++num;
                            fixupHolderList.m_values[index] = (FixupHolder)null;
                            if (!bObjectFullyComplete)
                            {
                                holder.DecrementFixupsRemaining(this);
                                holder1.RemoveDependency(holder.m_id);
                            }
                        }
                    }
                }
            }
            else
            {
                for (int index = 0; index < fixupHolderList.m_count; ++index)
                {
                    FixupHolder fixup = fixupHolderList.m_values[index];
                    if (fixup != null && this.GetCompletionInfo(fixup, out holder1, out member, bObjectFullyComplete))
                    {
                        if (holder1.TypeLoadExceptionReachable)
                        {
                            holder.TypeLoadException = holder1.TypeLoadException;
                            if (holder.Reachable)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_TypeLoadFailure", (object)holder.TypeLoadException.TypeName));
                            }
                        }
                        if (holder.Reachable)
                        {
                            holder1.Reachable = true;
                        }
                        switch (fixup.m_fixupType)
                        {
                        case 1:
                            if (holder.RequiresValueTypeFixup)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_ValueTypeFixup"));
                            }
                            ((Array)holder.ObjectValue).SetValue(holder1.ObjectValue, (int[])member);
                            break;

                        case 2:
                            MemberInfo fi = (MemberInfo)member;
                            if (fi.MemberType != MemberTypes.Field)
                            {
                                throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                            }
                            if (holder.RequiresValueTypeFixup && holder.ValueTypeFixupPerformed)
                            {
                                if (!this.DoValueTypeFixup((FieldInfo)fi, holder, holder1.ObjectValue))
                                {
                                    throw new SerializationException(Environment.GetResourceString("Serialization_PartialValueTypeFixup"));
                                }
                            }
                            else
                            {
                                FormatterServices.SerializationSetValue(fi, holder.ObjectValue, holder1.ObjectValue);
                            }
                            if (holder1.RequiresValueTypeFixup)
                            {
                                holder1.ValueTypeFixupPerformed = true;
                                break;
                            }
                            break;

                        default:
                            throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                        }
                        ++num;
                        fixupHolderList.m_values[index] = (FixupHolder)null;
                        if (!bObjectFullyComplete)
                        {
                            holder.DecrementFixupsRemaining(this);
                            holder1.RemoveDependency(holder.m_id);
                        }
                    }
                }
            }
            this.m_fixupCount = this.m_fixupCount - (long)num;
            if (fixupHolderList.m_count != num)
            {
                return;
            }
            holder.m_missingElements = (FixupHolderList)null;
        }