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


C# WriteObjectInfo.ObjectEnd方法代码示例

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


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

示例1: WriteMembers

        // Writes the members of an object
        private void WriteMembers(NameInfo memberNameInfo,
                                  NameInfo memberTypeNameInfo,
                                  object memberData,
                                  WriteObjectInfo objectInfo,
                                  NameInfo typeNameInfo,
                                  WriteObjectInfo memberObjectInfo)
        {
            Type memberType = memberNameInfo._type;
            bool assignUniqueIdToValueType = false;

            // Types are transmitted for a member as follows:
            // The member is of type object
            // The member object of type is ISerializable and
            //  Binary - Types always transmitted.

            if (ReferenceEquals(memberType, Converter.s_typeofObject) || Nullable.GetUnderlyingType(memberType) != null)
            {
                memberTypeNameInfo._transmitTypeOnMember = true;
                memberNameInfo._transmitTypeOnMember = true;
            }

            if (CheckTypeFormat(_formatterEnums._typeFormat, FormatterTypeStyle.TypesAlways) || (objectInfo._isSi))
            {
                memberTypeNameInfo._transmitTypeOnObject = true;
                memberNameInfo._transmitTypeOnObject = true;
                memberNameInfo._isParentTypeOnObject = true;
            }

            if (CheckForNull(objectInfo, memberNameInfo, memberTypeNameInfo, memberData))
            {
                return;
            }

            object outObj = memberData;
            Type outType = null;

            // If member type does not equal data type, transmit type on object.
            if (memberTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Invalid)
            {
                outType = GetType(outObj);
                if (!ReferenceEquals(memberType, outType))
                {
                    memberTypeNameInfo._transmitTypeOnMember = true;
                    memberNameInfo._transmitTypeOnMember = true;
                }
            }

            if (ReferenceEquals(memberType, Converter.s_typeofObject))
            {
                assignUniqueIdToValueType = true;
                memberType = GetType(memberData);
                if (memberObjectInfo == null)
                {
                    TypeToNameInfo(memberType, memberTypeNameInfo);
                }
                else
                {
                    TypeToNameInfo(memberObjectInfo, memberTypeNameInfo);
                }
            }

            if (memberObjectInfo != null && memberObjectInfo._isArray)
            {
                // Array
                long arrayId = 0;
                if (outType == null)
                {
                    outType = GetType(outObj);
                }
                
                // outObj is an array. It can never be a value type..
                arrayId = Schedule(outObj, false, null, memberObjectInfo);
                if (arrayId > 0)
                {
                    // Array as object
                    memberNameInfo._objectId = arrayId;
                    WriteObjectRef(memberNameInfo, arrayId);
                }
                else
                {
                    // Nested Array
                    _serWriter.WriteMemberNested(memberNameInfo);

                    memberObjectInfo._objectId = arrayId;
                    memberNameInfo._objectId = arrayId;
                    WriteArray(memberObjectInfo, memberNameInfo, memberObjectInfo);
                    objectInfo.ObjectEnd();
                }
                return;
            }

            if (!WriteKnownValueClass(memberNameInfo, memberTypeNameInfo, memberData))
            {
                if (outType == null)
                {
                    outType = GetType(outObj);
                }

                long memberObjectId = Schedule(outObj, assignUniqueIdToValueType, outType, memberObjectInfo);
//.........这里部分代码省略.........
开发者ID:Corillian,项目名称:corefx,代码行数:101,代码来源:BinaryObjectWriter.cs

示例2: WriteMembers

        [System.Security.SecurityCritical]  // auto-generated
        private void WriteMembers(NameInfo memberNameInfo,
                                  NameInfo memberTypeNameInfo,
                                  Object   memberData,
                                  WriteObjectInfo objectInfo,
                                  NameInfo typeNameInfo,
                                  WriteObjectInfo memberObjectInfo
                                 )
        {
            SerTrace.Log( this, "WriteMembers Entry memberType: ",memberTypeNameInfo.NIname," memberName: ",memberNameInfo.NIname," data: ",memberData," objectId: ",objectInfo.objectId, " Container object ",objectInfo.obj, " memberObjectinfo ",memberObjectInfo);
            Type memberType = memberNameInfo.NItype;
            bool assignUniqueIdToValueType = false;

            // Types are transmitted for a member as follows:
            // The member is of type object
            // The member object of type is ISerializable and
            //  Binary - Types always transmitted.

            if (Object.ReferenceEquals(memberType, Converter.typeofObject) || (object)Nullable.GetUnderlyingType(memberType) != null)
            {
                memberTypeNameInfo.NItransmitTypeOnMember  = true;
                memberNameInfo.NItransmitTypeOnMember  = true;              
            }

            if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways) || (objectInfo.isSi) )
            {
                memberTypeNameInfo.NItransmitTypeOnObject  = true;
                memberNameInfo.NItransmitTypeOnObject  = true;
                memberNameInfo.NIisParentTypeOnObject = true;
            }

            if (CheckForNull(objectInfo, memberNameInfo, memberTypeNameInfo, memberData))
            {
                return;
            }

            Object outObj = memberData;
            Type outType = null;

            // If member type does not equal data type, transmit type on object.
            if (memberTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Invalid)
            {
                outType = GetType(outObj);
                if (!Object.ReferenceEquals(memberType, outType))
                {
                    memberTypeNameInfo.NItransmitTypeOnMember  = true;
                    memberNameInfo.NItransmitTypeOnMember  = true;    
                }
            }

            if (Object.ReferenceEquals(memberType, Converter.typeofObject))
            {
                assignUniqueIdToValueType = true;
                memberType = GetType(memberData);
                if (memberObjectInfo == null)
                    TypeToNameInfo(memberType, memberTypeNameInfo);
                else
                    TypeToNameInfo(memberObjectInfo, memberTypeNameInfo);                   
                SerTrace.Log( this, "WriteMembers memberType Object, actual memberType ",memberType);                                                                               
            }

            if (memberObjectInfo != null && memberObjectInfo.isArray)
            {
                // Array
                SerTrace.Log( this, "WriteMembers IsArray");

                long arrayId = 0;
                if ((object)outType == null)
                    outType = GetType(outObj);
                // outObj is an array. It can never be a value type..
                arrayId = Schedule(outObj, false, null, memberObjectInfo);
                if (arrayId > 0)
                {
                    // Array as object
                    SerTrace.Log( this, "WriteMembers Schedule 3");
                    memberNameInfo.NIobjectId = arrayId;
                    WriteObjectRef(memberNameInfo, arrayId); 
                }
                else
                {
                    // Nested Array
                    serWriter.WriteMemberNested(memberNameInfo);

                    memberObjectInfo.objectId = arrayId;
                    memberNameInfo.NIobjectId = arrayId;
                    WriteArray(memberObjectInfo, memberNameInfo, memberObjectInfo);
                    objectInfo.ObjectEnd();

                }
                SerTrace.Log( this, "WriteMembers Array Exit ");
                return;
            }

            if (!WriteKnownValueClass(memberNameInfo, memberTypeNameInfo, memberData))
            {
                SerTrace.Log( this, "WriteMembers Object ",memberData);

#if false
                // Value or NO_ID, need to explicitly check for IsValue because a top level
                // value class has an objectId of 1
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:BinaryObjectWriter.cs

示例3: WriteMembers

 private void WriteMembers(NameInfo memberNameInfo, NameInfo memberTypeNameInfo, object memberData, WriteObjectInfo objectInfo, NameInfo typeNameInfo, WriteObjectInfo memberObjectInfo)
 {
     Type nItype = memberNameInfo.NItype;
     bool assignUniqueIdToValueType = false;
     if (object.ReferenceEquals(nItype, Converter.typeofObject) || (Nullable.GetUnderlyingType(nItype) != null))
     {
         memberTypeNameInfo.NItransmitTypeOnMember = true;
         memberNameInfo.NItransmitTypeOnMember = true;
     }
     if (this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways) || objectInfo.isSi)
     {
         memberTypeNameInfo.NItransmitTypeOnObject = true;
         memberNameInfo.NItransmitTypeOnObject = true;
         memberNameInfo.NIisParentTypeOnObject = true;
     }
     if (!this.CheckForNull(objectInfo, memberNameInfo, memberTypeNameInfo, memberData))
     {
         object obj2 = memberData;
         Type objB = null;
         if (memberTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Invalid)
         {
             objB = this.GetType(obj2);
             if (!object.ReferenceEquals(nItype, objB))
             {
                 memberTypeNameInfo.NItransmitTypeOnMember = true;
                 memberNameInfo.NItransmitTypeOnMember = true;
             }
         }
         if (object.ReferenceEquals(nItype, Converter.typeofObject))
         {
             assignUniqueIdToValueType = true;
             nItype = this.GetType(memberData);
             if (memberObjectInfo == null)
             {
                 this.TypeToNameInfo(nItype, memberTypeNameInfo);
             }
             else
             {
                 this.TypeToNameInfo(memberObjectInfo, memberTypeNameInfo);
             }
         }
         if ((memberObjectInfo != null) && memberObjectInfo.isArray)
         {
             long objectId = 0L;
             if (objB == null)
             {
                 objB = this.GetType(obj2);
             }
             objectId = this.Schedule(obj2, false, null, memberObjectInfo);
             if (objectId > 0L)
             {
                 memberNameInfo.NIobjectId = objectId;
                 this.WriteObjectRef(memberNameInfo, objectId);
             }
             else
             {
                 this.serWriter.WriteMemberNested(memberNameInfo);
                 memberObjectInfo.objectId = objectId;
                 memberNameInfo.NIobjectId = objectId;
                 this.WriteArray(memberObjectInfo, memberNameInfo, memberObjectInfo);
                 objectInfo.ObjectEnd();
             }
         }
         else if (!this.WriteKnownValueClass(memberNameInfo, memberTypeNameInfo, memberData))
         {
             if (objB == null)
             {
                 objB = this.GetType(obj2);
             }
             long num2 = this.Schedule(obj2, assignUniqueIdToValueType, objB, memberObjectInfo);
             if (num2 < 0L)
             {
                 memberObjectInfo.objectId = num2;
                 NameInfo info = this.TypeToNameInfo(memberObjectInfo);
                 info.NIobjectId = num2;
                 this.Write(memberObjectInfo, memberNameInfo, info);
                 this.PutNameInfo(info);
                 memberObjectInfo.ObjectEnd();
             }
             else
             {
                 memberNameInfo.NIobjectId = num2;
                 this.WriteObjectRef(memberNameInfo, num2);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:87,代码来源:ObjectWriter.cs


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