• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Serialization.ObjectHolder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ObjectHolder类属于System.Runtime.Serialization命名空间,在下文中一共展示了ObjectHolder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ObjectHolder

 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();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:26,代码来源:ObjectHolder.cs


示例2: AddObjectHolder

 private void AddObjectHolder(ObjectHolder holder)
 {
     if ((holder.m_id >= this.m_objects.Length) && (this.m_objects.Length != 0x1000))
     {
         int num = 0x1000;
         if (holder.m_id < 0x800L)
         {
             num = this.m_objects.Length * 2;
             while ((num <= holder.m_id) && (num < 0x1000))
             {
                 num *= 2;
             }
             if (num > 0x1000)
             {
                 num = 0x1000;
             }
         }
         ObjectHolder[] destinationArray = new ObjectHolder[num];
         Array.Copy(this.m_objects, destinationArray, this.m_objects.Length);
         this.m_objects = destinationArray;
     }
     int index = (int) (holder.m_id & 0xfffL);
     ObjectHolder holder2 = this.m_objects[index];
     holder.m_next = holder2;
     this.m_objects[index] = holder;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:ObjectManager.cs


示例3: Add

 internal virtual void Add(ObjectHolder value)
 {
     if (this.m_count == this.m_values.Length)
     {
         this.EnlargeArray();
     }
     this.m_values[this.m_count++] = value;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:ObjectHolderList.cs


示例4: FindOrCreateObjectHolder

 internal ObjectHolder FindOrCreateObjectHolder(long objectID)
 {
     ObjectHolder holder;
     holder = FindObjectHolder(objectID);
     if (holder == null)
     {
         holder = new ObjectHolder(objectID);
         AddObjectHolder(holder);
     }
     return holder;
 }
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:ObjectManager.cs


示例5: EnlargeArray

 private void EnlargeArray()
 {
     int num = this.m_values.Length * 2;
     if (num < 0)
     {
         if (num == 0x7fffffff)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_TooManyElements"));
         }
         num = 0x7fffffff;
     }
     ObjectHolder[] destinationArray = new ObjectHolder[num];
     Array.Copy(this.m_values, destinationArray, this.m_count);
     this.m_values = destinationArray;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:15,代码来源:ObjectHolderList.cs


示例6: EnlargeArray

     private void EnlargeArray() {
         BCLDebug.Trace("SER", "[ObjectHolderList.EnlargeArray]Enlarging array of size ", m_values.Length);
         int newLength = m_values.Length*2;
         if (newLength<0) {
             if (newLength==Int32.MaxValue) {
                 throw new SerializationException(Environment.GetResourceString("Serialization_TooManyElements"));
             }
             newLength=Int32.MaxValue;
         }
 
         ObjectHolder[] temp = new ObjectHolder[newLength];
         Array.Copy(m_values, temp, m_count);
         m_values = temp;
     }
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:objectmanager.cs


示例7: AddObjectHolder

     /*===============================AddObjectHolder================================
     **Action: Add the provided ObjectHolder to collection of ObjectHolders. 
     **        Enlarges the collection as appropriate.
     **Returns: void
     **Arguments: holder The ObjectHolder to be added.
     **Exceptions: Internal only.  Caller should verify that <CODE>holder</CODE> is 
     **            not null.
     ==============================================================================*/
     private void AddObjectHolder(ObjectHolder holder) {
 
         BCLDebug.Assert(holder!=null,"holder!=null");
         BCLDebug.Trace("SER", "[AddObjectHolder]Adding ObjectHolder with id: ", holder.m_id, " Current Bins: ", m_objects.Length);
         BCLDebug.Assert(holder.m_id>=0,"holder.m_id>=0");
 
         //If the id that we need to place is greater than our current length, and less
         //than the maximum allowable size of the array.  We need to double the size
         //of the array.  If the array has already reached it's maximum allowable size,
         //we chain elements off of the buckets.
         if (holder.m_id>=m_objects.Length && m_objects.Length != MaxArraySize) {
             int newSize=MaxArraySize;
 
             if (holder.m_id<(MaxArraySize/2)) {
                 newSize = (m_objects.Length * 2);
 
                 //Keep doubling until we're larger than our target size.
                 //We could also do this with log operations, but that would
                 //be slower than the brute force approach.
                 while (newSize<=holder.m_id && newSize<MaxArraySize) {
                     newSize*=2;
                 }
                 
                 if (newSize>MaxArraySize) {
                     newSize=MaxArraySize;
                 }
             }
 
             BCLDebug.Trace("SER", "[AddObjectHolder]Reallocating m_objects to have ", newSize, " bins");
             ObjectHolder[] temp = new ObjectHolder[newSize];
             Array.Copy(m_objects, temp, m_objects.Length);
             m_objects = temp;
         }
             
         //Find the bin in which we live and make this new element the first element in the bin.
         int index = (int)(holder.m_id & ArrayMask);
         BCLDebug.Trace("SER", "[AddObjectHolder]Trying to put an object in bin ", index);
 
         ObjectHolder tempHolder = m_objects[index]; 
         holder.m_next = tempHolder;
         m_objects[index] = holder;
     }
开发者ID:ArildF,项目名称:masters,代码行数:50,代码来源:objectmanager.cs


示例8: Add

 internal virtual void Add(ObjectHolder value) {
     if (m_count==m_values.Length) {
         EnlargeArray();
     }
     m_values[m_count++]=value;
 }
开发者ID:ArildF,项目名称:masters,代码行数:6,代码来源:objectmanager.cs


示例9: Add

 internal void Add(ObjectHolder value)
 {
     if (_count == _values.Length)
     {
         EnlargeArray();
     }
     _values[_count++] = value;
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:ObjectManager.cs


示例10: ObjectHolder

        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;
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:25,代码来源:objectmanager.cs


示例11: ResolveObjectReference

        /*============================ResolveObjectReference============================
        **Action:Unfortunately, an ObjectReference could actually be a reference to another
        **       object reference and we don't know how far we have to tunnel until we can find the real object.  While
        **       we're still getting instances of IObjectReference back and we're still getting new objects, keep calling
        **       GetRealObject.  Once we've got the new object, take care of all of the fixups
        **       that we can do now that we've got it.
        ==============================================================================*/
        private bool ResolveObjectReference(ObjectHolder holder) {
            Object tempObject;
            BCLDebug.Assert(holder.IsIncompleteObjectReference,"holder.IsIncompleteObjectReference");

            //In the pathological case, an Object implementing IObjectReference could return a reference
            //to a different object which implements IObjectReference.  This makes us vulnerable to a 
            //denial of service attack and stack overflow.  If the depthCount becomes greater than
            //MaxReferenceDepth, we'll throw a SerializationException.
            int depthCount = 0;
            
            //We wrap this in a try/catch block to handle the case where we're trying to resolve a chained
            //list of object reference (e.g. an IObjectReference can't resolve itself without some information
            //that's currently missing from the graph).  We'll catch the NullReferenceException and come back
            //and try again later.  The downside of this scheme is that if the object actually needed to throw
            //a NullReferenceException, it's being caught and turned into a SerializationException with a
            //fairly cryptic message.
            try {
                do {
                    tempObject = holder.ObjectValue;
                    BCLDebug.Trace("SER", "[ResolveObjectReference]ID: ", holder.m_id);
                    BCLDebug.Trace("SER", "[ResolveObjectReference]HasISerializable: ", holder.HasISerializable);
                    holder.SetObjectValue(((IObjectReference)(holder.ObjectValue)).GetRealObject(m_context), this);
                    //The object didn't yet have enough information to resolve the reference, so we'll
                    //return false and the graph walker should call us back again after more objects have
                    //been resolved.
                    if (holder.ObjectValue==null) {
                        holder.SetObjectValue(tempObject, this);
                        BCLDebug.Trace("SER", "Object: ", holder.m_id, " did NOT have enough information to resolve the IObjectReference.");
                        return false;
                    }
                    if (depthCount++==MaxReferenceDepth) {
                        throw new SerializationException(Environment.GetResourceString("Serialization_TooManyReferences"));
                    }
                } while ((holder.ObjectValue is IObjectReference) && (tempObject!=holder.ObjectValue));
            } catch (NullReferenceException) {
                BCLDebug.Trace("SER", "[ResolveObjectReference]Caught exception trying to call GetRealObject.");
                return false;
            }
    
            BCLDebug.Trace("SER", "Object: ", holder.m_id, " resolved the IObjectReference.");
            holder.IsIncompleteObjectReference=false;
            DoNewlyRegisteredObjectFixups(holder);
            return true;
        }
开发者ID:ArildF,项目名称:masters,代码行数:51,代码来源:objectmanager.cs


示例12: 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


示例13: ResolveObjectReference

 private bool ResolveObjectReference(ObjectHolder holder)
 {
     int num = 0;
     try
     {
         object objectValue;
         do
         {
             objectValue = holder.ObjectValue;
             holder.SetObjectValue(((IObjectReference) holder.ObjectValue).GetRealObject(this.m_context), this);
             if (holder.ObjectValue == null)
             {
                 holder.SetObjectValue(objectValue, this);
                 return false;
             }
             if (num++ == 100)
             {
                 throw new SerializationException(Environment.GetResourceString("Serialization_TooManyReferences"));
             }
         }
         while ((holder.ObjectValue is IObjectReference) && (objectValue != holder.ObjectValue));
     }
     catch (NullReferenceException)
     {
         return false;
     }
     holder.IsIncompleteObjectReference = false;
     this.DoNewlyRegisteredObjectFixups(holder);
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:ObjectManager.cs


示例14: RegisterString

        internal void RegisterString(String obj, long objectID, SerializationInfo info, long idOfContainingObj, MemberInfo member) 
        {
            ObjectHolder temp;
            BCLDebug.Assert(member == null || member is FieldInfo, "RegisterString - member is FieldInfo");
            BCLDebug.Assert((FindObjectHolder(objectID) == null), "RegisterString - FindObjectHolder(objectID) == null");

            temp = new ObjectHolder(obj, objectID, info, null, idOfContainingObj, (FieldInfo)member, null);
            AddObjectHolder(temp);
            return;
        }
开发者ID:ArildF,项目名称:masters,代码行数:10,代码来源:objectmanager.cs


示例15: ObjectHolder

        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();
        }
开发者ID:dotnet,项目名称:corefx,代码行数:36,代码来源:ObjectManager.cs


示例16: AddObjectHolder

        private void AddObjectHolder(ObjectHolder holder)
        {
            Debug.Assert(holder != null, "holder!=null");
            Debug.Assert(holder._id >= 0, "holder.m_id>=0");

            //If the id that we need to place is greater than our current length, and less
            //than the maximum allowable size of the array.  We need to double the size
            //of the array.  If the array has already reached it's maximum allowable size,
            //we chain elements off of the buckets.
            if (holder._id >= _objects.Length && _objects.Length != MaxArraySize)
            {
                int newSize = MaxArraySize;

                if (holder._id < (MaxArraySize / 2))
                {
                    newSize = (_objects.Length * 2);

                    //Keep doubling until we're larger than our target size.
                    //We could also do this with log operations, but that would
                    //be slower than the brute force approach.
                    while (newSize <= holder._id && newSize < MaxArraySize)
                    {
                        newSize *= 2;
                    }

                    if (newSize > MaxArraySize)
                    {
                        newSize = MaxArraySize;
                    }
                }

                ObjectHolder[] temp = new ObjectHolder[newSize];
                Array.Copy(_objects, 0, temp, 0, _objects.Length);
                _objects = temp;
            }

            //Find the bin in which we live and make this new element the first element in the bin.
            int index = (int)(holder._id & ArrayMask);

            ObjectHolder tempHolder = _objects[index];
            holder._next = tempHolder;
            _objects[index] = holder;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:43,代码来源:ObjectManager.cs


示例17: RegisterObject

        public void RegisterObject(object obj, long objectID, SerializationInfo info, long idOfContainingObj, MemberInfo member, int[] arrayIndex)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }
            if (objectID <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(objectID), SR.ArgumentOutOfRange_ObjectID);
            }
            if (member != null && !(member is FieldInfo))
            {
                throw new SerializationException(SR.Serialization_UnknownMemberInfo);
            }

            ObjectHolder temp;
            ISerializationSurrogate surrogate = null;
            ISurrogateSelector useless;

            if (_selector != null)
            {
                Type selectorType = CanCallGetType(obj) ?
                    obj.GetType() :
                    typeof(MarshalByRefObject);

                //If we need a surrogate for this object, lets find it now.
                surrogate = _selector.GetSurrogate(selectorType, _context, out useless);
            }

            //The object is interested in DeserializationEvents so lets register it.
            if (obj is IDeserializationCallback)
            {
                DeserializationEventHandler d = new DeserializationEventHandler(((IDeserializationCallback)obj).OnDeserialization);
                AddOnDeserialization(d);
            }

            //Formatter developers may cache and reuse arrayIndex in their code.
            //So that we don't get bitten by this, take a copy up front.
            if (arrayIndex != null)
            {
                arrayIndex = (int[])arrayIndex.Clone();
            }

            //This is the first time which we've seen the object, we need to create a new holder.
            temp = FindObjectHolder(objectID);
            if (temp == null)
            {
                temp = new ObjectHolder(obj, objectID, info, surrogate, idOfContainingObj, (FieldInfo)member, arrayIndex);
                AddObjectHolder(temp);
                if (temp.RequiresDelayedFixup)
                {
                    SpecialFixupObjects.Add(temp);
                }

                // We cannot compute whether this has any fixups required or not
                AddOnDeserialized(obj);
                return;
            }

            //If the object isn't null, we've registered this before.  Not good.
            if (temp.ObjectValue != null)
            {
                throw new SerializationException(SR.Serialization_RegisterTwice);
            }

            //Complete the data in the ObjectHolder
            temp.UpdateData(obj, info, surrogate, idOfContainingObj, (FieldInfo)member, arrayIndex, this);

            // The following case will only be true when somebody has registered a fixup on an object before
            // registering the object itself.  I don't believe that most well-behaved formatters will do this,
            // but we need to allow it anyway.  We will walk the list of fixups which have been recorded on 
            // the new object and fix those that we can.  Because the user could still register later fixups
            // on this object, we won't call any implementations of ISerializable now.  If that's required,
            // it will have to be handled by the code in DoFixups.
            // README README: We have to do the UpdateData before 
            if (temp.DirectlyDependentObjects > 0)
            {
                CompleteObject(temp, false);
            }

            if (temp.RequiresDelayedFixup)
            {
                SpecialFixupObjects.Add(temp);
            }

            if (temp.CompletelyFixed)
            {
                //Here's where things get tricky.  If this isn't an instance of IObjectReference, we need to walk it's fixup 
                //chain and decrement the counters on anything that has reached 0.  Once we've notified all of the dependencies,
                //we can simply clear the list of dependent objects.
                DoNewlyRegisteredObjectFixups(temp);
                temp.DependentObjects = null;
            }

            //Register the OnDeserialized methods to be invoked after deserialization is complete
            if (temp.TotalDependentObjects > 0)
            {
                AddOnDeserialized(obj);
            }
            else
//.........这里部分代码省略.........
开发者ID:dotnet,项目名称:corefx,代码行数:101,代码来源:ObjectManager.cs


示例18: DoNewlyRegisteredObjectFixups

        /// <summary>
        /// This is called immediately after we register a new object.  Walk that objects
        /// dependency list (if it has one) and decrement the counters on each object for
        /// the number of unsatisfiable references.  If the count reaches 0, go ahead
        /// and process the object.
        /// </summary>
        /// <param name="holder">dependencies The list of dependent objects</param>
        private void DoNewlyRegisteredObjectFixups(ObjectHolder holder)
        {
            if (holder.CanObjectValueChange)
            {
                return;
            }

            //If we don't have any dependencies, we're done.
            LongList dependencies = holder.DependentObjects;
            if (dependencies == null)
            {
                return;
            }

            //Walk all of the dependencies and decrement the counter on each of uncompleted objects.
            //If one of the counters reaches 0, all of it's fields have been completed and we should
            //go take care of its fixups.
            dependencies.StartEnumeration();
            while (dependencies.MoveNext())
            {
                ObjectHolder temp = FindObjectHolder(dependencies.Current);
                Debug.Assert(temp.DirectlyDependentObjects > 0, "temp.m_missingElementsRemaining>0");
                temp.DecrementFixupsRemaining(this);
                if (((temp.DirectlyDependentObjects)) == 0)
                {
                    // If this is null, we have the case where a fixup was registered for a child, the object 
                    // required by the fixup was provided, and the object to be fixed hasn't yet been seen.  
                    if (temp.ObjectValue != null)
                    {
                        CompleteObject(temp, true);
                    }
                    else
                    {
                        temp.MarkForCompletionWhenAvailable();
                    }
                }
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:45,代码来源:ObjectManager.cs


示例19: EnlargeArray

        private void EnlargeArray()
        {
            int newLength = _values.Length * 2;
            if (newLength < 0)
            {
                if (newLength == int.MaxValue)
                {
                    throw new SerializationException(SR.Serialization_TooManyElements);
                }
                newLength = int.MaxValue;
            }

            ObjectHolder[] temp = new ObjectHolder[newLength];
            Array.Copy(_values, 0, temp, 0, _count);
            _values = temp;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:ObjectManager.cs


示例20: GetCompletionInfo

        private bool GetCompletionInfo(FixupHolder fixup, out ObjectHolder holder, out Object member, bool bThrowIfMissing) {
    
            //Set the member id (String or MemberInfo) for the member being fixed up.
            member = fixup.m_fixupInfo;
    
            //Find the object required for the fixup.  Throw if we can't find it.
            holder = FindObjectHolder(fixup.m_id);
            BCLDebug.Trace("SER", "[ObjectManager.GetCompletionInfo]Getting fixup info for: ", fixup.m_id);

            // CompletelyFixed is our poorly named property which indicates if something requires a SerializationInfo fixup
            // or is an incomplete object reference.  We have this particular branch to handle valuetypes which implement
            // ISerializable.  In that case, we can't do any fixups on them later, so we need to delay the fixups further.
            if (!holder.CompletelyFixed) {
                if (holder.ObjectValue!=null && holder.ObjectValue is ValueType) {
                    BCLDebug.Trace("SER", "[ObjectManager.GetCompletionInfo]ValueType implementing ISerializable.  Delaying fixup.");
                    SpecialFixupObjects.Add(holder);
                    return false;
                }
            }

            if (holder==null || holder.IsIncompleteObjectReference || holder.ObjectValue==null) {
                if (bThrowIfMissing) {
                    BCLDebug.Trace("SER", "[GetCompletionInfo]Unable to find fixup for: ", fixup.m_id);
                    BCLDebug.Trace("SER", "[GetCompletionInfo]Holder: ", ((holder==null)?"<null>":"Non Null"));
                    BCLDebug.Trace("SER", "[GetCompletionInfo]IsIncomplete: ", (holder.IsIncompleteObjectReference));
                    BCLDebug.Trace("SER", "[GetCompletionInfo]Object: ", ((holder.ObjectValue==null)?"<null>":"Non Null"));
                    if (holder==null) {
                        throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_NeverSeen"), fixup.m_id));
                    }
                    if (holder.IsIncompleteObjectReference) {
                        throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_IORIncomplete"), fixup.m_id));
                    }
                    throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_ObjectNotSupplied"), fixup.m_id));
                }
                return false;
            }
            return true;
        }
开发者ID:ArildF,项目名称:masters,代码行数:38,代码来源:objectmanager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Serialization.ObjectManager类代码示例发布时间:2022-05-26
下一篇:
C# Serialization.NetDataContractSerializer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap