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


C# WriteObjectInfo.GetMemberInfo方法代码示例

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


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

示例1: Write

        // Writes a given object to the stream.
        private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
        {
            object obj = objectInfo._obj;
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(objectInfo) + "." + nameof(objectInfo._obj));
            }
            Type objType = objectInfo._objectType;
            long objectId = objectInfo._objectId;

            if (ReferenceEquals(objType, Converter.s_typeofString))
            {
                // Top level String
                memberNameInfo._objectId = objectId;
                _serWriter.WriteObjectString((int)objectId, obj.ToString());
            }
            else
            {
                if (objectInfo._isArray)
                {
                    WriteArray(objectInfo, memberNameInfo, null);
                }
                else
                {
                    string[] memberNames;
                    Type[] memberTypes;
                    object[] memberData;

                    objectInfo.GetMemberInfo(out memberNames, out memberTypes, out memberData);

                    // Only Binary needs to transmit types for ISerializable because the binary formatter transmits the types in URT format.
                    // Soap transmits all types as strings, so it is up to the ISerializable object to convert the string back to its URT type
                    if (objectInfo._isSi || CheckTypeFormat(_formatterEnums._typeFormat, FormatterTypeStyle.TypesAlways))
                    {
                        memberNameInfo._transmitTypeOnObject = true;
                        memberNameInfo._isParentTypeOnObject = true;
                        typeNameInfo._transmitTypeOnObject = true;
                        typeNameInfo._isParentTypeOnObject = true;
                    }

                    var memberObjectInfos = new WriteObjectInfo[memberNames.Length];

                    // Get assembly information
                    // Binary Serializer, assembly names need to be
                    // written before objects are referenced.
                    // GetAssemId here will write out the
                    // assemblyStrings at the right Binary
                    // Serialization object boundary.
                    for (int i = 0; i < memberTypes.Length; i++)
                    {
                        Type type =
                            memberTypes[i] != null ? memberTypes[i] :
                            memberData[i] != null ? GetType(memberData[i]) :
                            Converter.s_typeofObject;

                        InternalPrimitiveTypeE code = ToCode(type);
                        if ((code == InternalPrimitiveTypeE.Invalid) &&
                            (!ReferenceEquals(type, Converter.s_typeofString)))
                        {
                            if (memberData[i] != null)
                            {
                                memberObjectInfos[i] = WriteObjectInfo.Serialize(
                                    memberData[i],
                                    _surrogates,
                                    _context,
                                    _serObjectInfoInit,
                                    _formatterConverter,
                                    this,
                                    _binder);
                                memberObjectInfos[i]._assemId = GetAssemblyId(memberObjectInfos[i]);
                            }
                            else
                            {
                                memberObjectInfos[i] = WriteObjectInfo.Serialize(
                                    memberTypes[i],
                                    _surrogates,
                                    _context,
                                    _serObjectInfoInit,
                                    _formatterConverter,
                                    _binder);
                                memberObjectInfos[i]._assemId = GetAssemblyId(memberObjectInfos[i]);
                            }
                        }
                    }
                    Write(objectInfo, memberNameInfo, typeNameInfo, memberNames, memberTypes, memberData, memberObjectInfos);
                }
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:89,代码来源:BinaryObjectWriter.cs

示例2: Write

        [System.Security.SecurityCritical]  // auto-generated
        private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
        {       
#if _DEBUG                        
            SerTrace.Log( this, "Write 1 Entry objectInfo ",objectInfo,", memberNameInfo ",memberNameInfo,", typeNameInfo ",typeNameInfo);
            memberNameInfo.Dump("Write memberNameInfo");
            typeNameInfo.Dump("Write typeNameInfo");
#endif            
            Object obj = objectInfo.obj;
            if (obj==null)
                throw new ArgumentNullException("objectInfo.obj", Environment.GetResourceString("ArgumentNull_Obj"));

            SerTrace.Log( this, "Write 1 objectInfo obj ",objectInfo.obj," objectId ", objectInfo.objectId, " objectType ", objectInfo.objectType);
            Type objType = objectInfo.objectType;
            long objectId = objectInfo.objectId;


            SerTrace.Log( this, "Write 1 ",obj," ObjectId ",objectId);

            if (Object.ReferenceEquals(objType, Converter.typeofString))
            {
                // Top level String
                memberNameInfo.NIobjectId = objectId;
                serWriter.WriteObjectString((int)objectId, obj.ToString());
            }
            else
            {

                if (objectInfo.isArray)
                {
                    WriteArray(objectInfo, memberNameInfo, null); 
                }
                else
                {
                    String[] memberNames;
                    Type[] memberTypes;
                    Object[] memberData;

                    objectInfo.GetMemberInfo(out memberNames, out memberTypes, out memberData);

                    // Only Binary needs to transmit types for ISerializable because the binary formatter transmits the types in URT format.
                    // Soap transmits all types as strings, so it is up to the ISerializable object to convert the string back to its URT type
                    if (objectInfo.isSi || CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
                    {
                        SerTrace.Log( this, "Write 1 TransmitOnObject ");
                        memberNameInfo.NItransmitTypeOnObject = true;
                        memberNameInfo.NIisParentTypeOnObject = true;
                        typeNameInfo.NItransmitTypeOnObject = true;
                        typeNameInfo.NIisParentTypeOnObject = true;                                             
                    }

                    WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[memberNames.Length];

                    // Get assembly information
                    // Binary Serializer, assembly names need to be
                    // written before objects are referenced.
                    // GetAssemId here will write out the
                    // assemblyStrings at the right Binary
                    // Serialization object boundary.
                    for (int i=0; i<memberTypes.Length; i++)
                    {
                        Type type;
                        if ((object)memberTypes[i] != null)
                            type = memberTypes[i];
                        else if (memberData[i] != null)
                            type = GetType(memberData[i]);
                        else
                            type = Converter.typeofObject;

                        SerTrace.Log( this, "Write 1 member type ",type);
                        InternalPrimitiveTypeE code = ToCode(type);
                        if ((code == InternalPrimitiveTypeE.Invalid) &&
                            (!Object.ReferenceEquals(type, Converter.typeofString)))
                        {
                            SerTrace.Log( this, "Write 1 Create ObjectInfo ", memberTypes[i], " memberData ",memberData[i]);
                            if (memberData[i] != null)
                            {
                                memberObjectInfos[i] =
                                WriteObjectInfo.Serialize
                                (
                                memberData[i],
                                m_surrogates,
                                m_context,
                                serObjectInfoInit,
                                m_formatterConverter,
                                this,
                                m_binder);                                    
                                memberObjectInfos[i].assemId = GetAssemblyId(memberObjectInfos[i]);
                            }
                            else
                            {
                                memberObjectInfos[i] =
                                WriteObjectInfo.Serialize
                                (
                                memberTypes[i],
                                m_surrogates,
                                m_context,
                                serObjectInfoInit,
                                m_formatterConverter,
                                m_binder
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:BinaryObjectWriter.cs

示例3: Write

 private void Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
 {
     object obj2 = objectInfo.obj;
     if (obj2 == null)
     {
         throw new ArgumentNullException("objectInfo.obj", Environment.GetResourceString("ArgumentNull_Obj"));
     }
     Type objectType = objectInfo.objectType;
     long objectId = objectInfo.objectId;
     if (object.ReferenceEquals(objectType, Converter.typeofString))
     {
         memberNameInfo.NIobjectId = objectId;
         this.serWriter.WriteObjectString((int) objectId, obj2.ToString());
     }
     else if (objectInfo.isArray)
     {
         this.WriteArray(objectInfo, memberNameInfo, null);
     }
     else
     {
         string[] strArray;
         Type[] typeArray;
         object[] objArray;
         objectInfo.GetMemberInfo(out strArray, out typeArray, out objArray);
         if (objectInfo.isSi || this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
         {
             memberNameInfo.NItransmitTypeOnObject = true;
             memberNameInfo.NIisParentTypeOnObject = true;
             typeNameInfo.NItransmitTypeOnObject = true;
             typeNameInfo.NIisParentTypeOnObject = true;
         }
         WriteObjectInfo[] memberObjectInfos = new WriteObjectInfo[strArray.Length];
         for (int i = 0; i < typeArray.Length; i++)
         {
             Type type;
             if (typeArray[i] != null)
             {
                 type = typeArray[i];
             }
             else if (objArray[i] != null)
             {
                 type = this.GetType(objArray[i]);
             }
             else
             {
                 type = Converter.typeofObject;
             }
             if ((this.ToCode(type) == InternalPrimitiveTypeE.Invalid) && !object.ReferenceEquals(type, Converter.typeofString))
             {
                 if (objArray[i] != null)
                 {
                     memberObjectInfos[i] = WriteObjectInfo.Serialize(objArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this, this.m_binder);
                     memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
                 }
                 else
                 {
                     memberObjectInfos[i] = WriteObjectInfo.Serialize(typeArray[i], this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, this.m_binder);
                     memberObjectInfos[i].assemId = this.GetAssemblyId(memberObjectInfos[i]);
                 }
             }
         }
         this.Write(objectInfo, memberNameInfo, typeNameInfo, strArray, typeArray, objArray, memberObjectInfos);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:64,代码来源:ObjectWriter.cs


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