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


C# Serialization.ObjectHolder类代码示例

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


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


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