当前位置: 首页>>代码示例>>C#>>正文


C# ObjectHolder.DecrementFixupsRemaining方法代码示例

本文整理汇总了C#中System.Runtime.Serialization.ObjectHolder.DecrementFixupsRemaining方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectHolder.DecrementFixupsRemaining方法的具体用法?C# ObjectHolder.DecrementFixupsRemaining怎么用?C# ObjectHolder.DecrementFixupsRemaining使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.Serialization.ObjectHolder的用法示例。


在下文中一共展示了ObjectHolder.DecrementFixupsRemaining方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompleteObject

        /*================================CompleteObject================================
        **Action:
        **Returns:
        **Arguments:
        **Exceptions:
        ==============================================================================*/
        internal void CompleteObject(ObjectHolder holder, bool bObjectFullyComplete) {
            FixupHolderList fixups=holder.m_missingElements;
            FixupHolder currentFixup;
            SerializationInfo si;
            Object fixupInfo=null;
            ObjectHolder tempObjectHolder=null;
            int fixupsPerformed=0;
            
            BCLDebug.Assert(holder!=null,"[ObjectManager.CompleteObject]holder.m_object!=null");
            if (holder.ObjectValue==null) {
                throw new SerializationException(Environment.GetResourceString("Serialization_MissingObject", holder.m_id));
            }
    
            if (fixups==null) {
                return;
            }

            //If either one of these conditions is true, we need to update the data in the
            //SerializationInfo before calling SetObjectData.
            if (holder.HasSurrogate || holder.HasISerializable) {
                si = holder.m_serInfo;

                if (si==null) {
                    throw new SerializationException(Environment.GetResourceString("Serialization_InvalidFixupDiscovered"));
                }

                BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Complete object ", holder.m_id, " of SI Type: ", si.FullTypeName);
                //Walk each of the fixups and complete the name-value pair in the SerializationInfo.
                if (fixups!=null) {
                    for (int i=0; i<fixups.m_count; i++) {
                        if (fixups.m_values[i]==null) {
                            continue;
                        }
                        BCLDebug.Assert(fixups.m_values[i].m_fixupType==FixupHolder.DelayedFixup,"fixups.m_values[i].m_fixupType==FixupHolder.DelayedFixup");
                        if (GetCompletionInfo(fixups.m_values[i], out tempObjectHolder, out fixupInfo, bObjectFullyComplete)) {
                            //Walk the SerializationInfo and find the member needing completion.  All we have to do
                            //at this point is set the member into the Object
                            BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Updating object ", holder.m_id, " with object ", tempObjectHolder.m_id);
                            Object holderValue = tempObjectHolder.ObjectValue;
                            if (CanCallGetType(holderValue)) {
                                si.UpdateValue((String)fixupInfo, holderValue, holderValue.GetType());
                            } else {
                                si.UpdateValue((String)fixupInfo, holderValue, typeof(MarshalByRefObject));
                            }
                            //Decrement our total number of fixups left to do.
                            fixupsPerformed++;
                            fixups.m_values[i]=null;
                            if (!bObjectFullyComplete) {
                                holder.DecrementFixupsRemaining(this);
                                tempObjectHolder.RemoveDependency(holder.m_id);
                            }
                        }
                    }
                }
              
            } else {
                BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Non-ISerializableObject: ", holder.m_id);
                for (int i=0; i<fixups.m_count; i++) {
                    currentFixup = fixups.m_values[i];
                    if (currentFixup==null) {
                        continue;
                    }
                    BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Getting fixup info for object: ", currentFixup.m_id);
                    if (GetCompletionInfo(currentFixup, out tempObjectHolder, out fixupInfo, bObjectFullyComplete)) {
                        BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Fixing up: ", currentFixup.m_id);
                        //There are two types of fixups that we could be doing: array or member.  
                        //Delayed Fixups should be handled by the above branch.
                        switch(currentFixup.m_fixupType) {
                        case FixupHolder.ArrayFixup:
                            BCLDebug.Assert(holder.ObjectValue is Array,"holder.ObjectValue is Array");
                            if (holder.RequiresValueTypeFixup) {
                                throw new SerializationException(Environment.GetResourceString("Serialization_ValueTypeFixup"));
                            } else {
                                ((Array)(holder.ObjectValue)).SetValue(tempObjectHolder.ObjectValue, ((int[])fixupInfo));
                            }
                            break;
                        case FixupHolder.MemberFixup:
                            BCLDebug.Assert(fixupInfo is MemberInfo,"fixupInfo is MemberInfo");
                            //Fixup the member directly.
                            MemberInfo tempMember = (MemberInfo)fixupInfo;
                            if (tempMember.MemberType==MemberTypes.Field) {
                                BCLDebug.Trace("SER", "[ObjectManager.CompleteObject]Fixing member: ", tempMember.Name, " in object ", holder.m_id,
                                               " with object ", tempObjectHolder.m_id);

                                // If we have a valuetype that's been boxed to an object and requires a fixup,
                                // there are two possible states:
                                // (a)The valuetype has never been fixed up into it's container.  In this case, we should
                                // just fix up the boxed valuetype.  The task of pushing that valuetype into it's container
                                // will be handled later.  This case is handled by the else clause of the following statement.
                                // (b)The valuetype has already been inserted into it's container.  In that case, we need
                                // to go through the more complicated path laid out in DoValueTypeFixup. We can tell that the
                                // valuetype has already been inserted into it's container because we set ValueTypeFixupPerformed
                                // to true when we do this.
                                if (holder.RequiresValueTypeFixup && holder.ValueTypeFixupPerformed) {
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:objectmanager.cs

示例2: CompleteObject

        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(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_0242;
                                }
                                if (!this.DoValueTypeFixup((FieldInfo) info2, holder, holder3.ObjectValue))
                                {
                                    throw new SerializationException(Environment.GetResourceString("Serialization_PartialValueTypeFixup"));
                                }
                                goto Label_0256;

                            default:
                                throw new SerializationException(Environment.GetResourceString("Serialization_UnableToFixup"));
                        }
                        ((Array) holder.ObjectValue).SetValue(holder3.ObjectValue, (int[]) member);
                        goto Label_0289;
                    Label_0242:
                        FormatterServices.SerializationSetValue(info2, holder.ObjectValue, holder3.ObjectValue);
                    Label_0256:
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ObjectManager.cs


注:本文中的System.Runtime.Serialization.ObjectHolder.DecrementFixupsRemaining方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。