當前位置: 首頁>>代碼示例>>C#>>正文


C# Binary.WriteObjectInfo類代碼示例

本文整理匯總了C#中System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo的典型用法代碼示例。如果您正苦於以下問題:C# WriteObjectInfo類的具體用法?C# WriteObjectInfo怎麽用?C# WriteObjectInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WriteObjectInfo類屬於System.Runtime.Serialization.Formatters.Binary命名空間,在下文中一共展示了WriteObjectInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAssemblyId

 private long GetAssemblyId(WriteObjectInfo objectInfo)
 {
     if (this.assemblyToIdTable == null)
     {
         this.assemblyToIdTable = new Hashtable(5);
     }
     long num = 0L;
     bool isNew = false;
     string assemblyString = objectInfo.GetAssemblyString();
     string str2 = assemblyString;
     if (assemblyString.Length == 0)
     {
         return 0L;
     }
     if (assemblyString.Equals(Converter.urtAssemblyString))
     {
         return 0L;
     }
     if (this.assemblyToIdTable.ContainsKey(assemblyString))
     {
         num = (long) this.assemblyToIdTable[assemblyString];
         isNew = false;
     }
     else
     {
         num = this.InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
         this.assemblyToIdTable[assemblyString] = num;
     }
     this.serWriter.WriteAssembly(objectInfo.objectType, str2, (int) num, isNew);
     return num;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:31,代碼來源:ObjectWriter.cs

示例2: GetBinaryTypeInfo

 internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
 {
     BinaryTypeEnum primitive;
     assemId = 0;
     typeInformation = null;
     if (object.ReferenceEquals(type, Converter.typeofString))
     {
         return BinaryTypeEnum.String;
     }
     if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi)) && object.ReferenceEquals(type, Converter.typeofObject))
     {
         return BinaryTypeEnum.Object;
     }
     if (object.ReferenceEquals(type, Converter.typeofStringArray))
     {
         return BinaryTypeEnum.StringArray;
     }
     if (object.ReferenceEquals(type, Converter.typeofObjectArray))
     {
         return BinaryTypeEnum.ObjectArray;
     }
     if (Converter.IsPrimitiveArray(type, out typeInformation))
     {
         return BinaryTypeEnum.PrimitiveArray;
     }
     InternalPrimitiveTypeE ee = objectWriter.ToCode(type);
     switch (ee)
     {
         case InternalPrimitiveTypeE.Invalid:
         {
             string fullName = null;
             if (objectInfo == null)
             {
                 fullName = type.Assembly.FullName;
                 typeInformation = type.FullName;
             }
             else
             {
                 fullName = objectInfo.GetAssemblyString();
                 typeInformation = objectInfo.GetTypeFullName();
             }
             if (fullName.Equals(Converter.urtAssemblyString))
             {
                 primitive = BinaryTypeEnum.ObjectUrt;
                 assemId = 0;
                 return primitive;
             }
             primitive = BinaryTypeEnum.ObjectUser;
             assemId = (int) objectInfo.assemId;
             if (assemId == 0)
             {
                 throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { typeInformation }));
             }
             return primitive;
         }
     }
     primitive = BinaryTypeEnum.Primitive;
     typeInformation = ee;
     return primitive;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:60,代碼來源:BinaryConverter.cs

示例3: CheckForNull

 private bool CheckForNull(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, object data)
 {
     bool flag = false;
     if (data == null)
     {
         flag = true;
     }
     if (flag && ((((this.formatterEnums.FEserializerTypeEnum == InternalSerializerTypeE.Binary) || memberNameInfo.NIisArrayItem) || (memberNameInfo.NItransmitTypeOnObject || memberNameInfo.NItransmitTypeOnMember)) || (objectInfo.isSi || this.CheckTypeFormat(this.formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))))
     {
         if (typeNameInfo.NIisArrayItem)
         {
             if (typeNameInfo.NIarrayEnum == InternalArrayTypeE.Single)
             {
                 this.serWriter.WriteDelayedNullItem();
                 return flag;
             }
             this.serWriter.WriteNullItem(memberNameInfo, typeNameInfo);
             return flag;
         }
         this.serWriter.WriteNullMember(memberNameInfo, typeNameInfo);
     }
     return flag;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:23,代碼來源:ObjectWriter.cs

示例4: WriteObjectByteArray

        [System.Security.SecurityCritical]  // auto-generated
        internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Byte[] byteA) 
        {
#if _DEBUG 
            arrayNameInfo.Dump("WriteObjectByteArray arrayNameInfo"); 
            arrayElemTypeNameInfo.Dump("WriteObjectByteArray arrayElemTypeNameInfo");
#endif 
            InternalWriteItemNull();
            WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA);
        }
開發者ID:sjyanxin,項目名稱:WPFSource,代碼行數:10,代碼來源:BinaryFormatterWriter.cs

示例5: Schedule

        private long Schedule(Object obj, bool assignUniqueIdToValueType, Type type, WriteObjectInfo objectInfo)
        {
            SerTrace.Log( this, "Schedule Entry obj ",obj," type ", type, " objectInfo ",objectInfo);

            bool isNew;
            long id;

            if (obj==null)
            {
                SerTrace.Log(this, "Schedule Obj Null, id = 0 ");
                return 0;
            }

            id = InternalGetId(obj, assignUniqueIdToValueType, type, out isNew);           

            if (isNew && id > 0)
            {
                if (objectInfo == null)
                    m_objectQueue.Enqueue(obj);
                else
                    m_objectQueue.Enqueue(objectInfo);

            }
            SerTrace.Log( this, "Schedule Exit, id: ",id," isNew: ",isNew);     
            return id;

        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:27,代碼來源:BinaryObjectWriter.cs

示例6: WriteRectangle

        [System.Security.SecurityCritical]  // auto-generated
        private void WriteRectangle(WriteObjectInfo objectInfo, int rank, int[] maxA, System.Array array, NameInfo arrayElemNameTypeInfo, int[] lowerBoundA)
        {
            IndexTraceMessage("WriteRectangle  Entry "+rank, maxA);
            int[] currentA = new int[rank];
            int[] indexMap = null;
            bool isLowerBound = false;
            if (lowerBoundA != null)
            {
                for (int i=0; i<rank; i++)
                {
                    if (lowerBoundA[i] != 0)
                        isLowerBound = true;
                }
            }
            if (isLowerBound)
                indexMap = new int[rank];

            bool isLoop = true;
            while (isLoop)
            {
                isLoop = false;
                if (isLowerBound)
                { 
                    for (int i=0; i<rank; i++)
                    {
                        indexMap[i] = currentA[i]+lowerBoundA[i];
                    }

                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(indexMap));
                }
                else
                    WriteArrayMember(objectInfo, arrayElemNameTypeInfo, array.GetValue(currentA));          
                for (int irank = rank-1; irank>-1; irank--)
                {
                    // Find the current or lower dimension which can be incremented.
                    if (currentA[irank] < maxA[irank]-1)
                    {
                        // The current dimension is at maximum. Increase the next lower dimension by 1
                        currentA[irank]++;
                        if (irank < rank-1)
                        {
                            // The current dimension and higher dimensions are zeroed.
                            for (int i = irank+1; i<rank; i++)
                                currentA[i] = 0;
                        }
                        isLoop = true;
                        break;                  
                    }

                }
            }
            SerTrace.Log( this, "WriteRectangle  Exit ");
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:54,代碼來源:BinaryObjectWriter.cs

示例7: GetBinaryTypeInfo

        // From the type create the BinaryTypeEnum and typeInformation which describes the type on the wire
 
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, String typeName, ObjectWriter objectWriter, out Object typeInformation, out int assemId)
        {
            SerTrace.Log("BinaryConverter", "GetBinaryTypeInfo Entry type ",type,", typeName ",typeName," objectInfo "+objectInfo);
            BinaryTypeEnum binaryTypeEnum; 

            assemId = 0; 
            typeInformation = null; 

            if (Object.ReferenceEquals(type, Converter.typeofString)) 
                binaryTypeEnum = BinaryTypeEnum.String;
            else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi))
                     && (Object.ReferenceEquals(type, Converter.typeofObject)))
            { 
                // If objectInfo.Si then can be a surrogate which will change the type
                binaryTypeEnum = BinaryTypeEnum.Object; 
            } 
            else if (Object.ReferenceEquals(type, Converter.typeofStringArray))
                binaryTypeEnum = BinaryTypeEnum.StringArray; 
            else if (Object.ReferenceEquals(type, Converter.typeofObjectArray))
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray; 
            else
            { 
                InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type); 
                switch (primitiveTypeEnum)
                { 
                    case InternalPrimitiveTypeE.Invalid:
                        String assembly = null;
                        if (objectInfo == null)
                        { 
                            assembly = type.Assembly.FullName;
                            typeInformation = type.FullName; 
                        } 
                        else
                        { 
                            assembly = objectInfo.GetAssemblyString();
                            typeInformation = objectInfo.GetTypeFullName();
                        }
 
                        if (assembly.Equals(Converter.urtAssemblyString))
                        { 
                            binaryTypeEnum = BinaryTypeEnum.ObjectUrt; 
                            assemId = 0;
                        } 
                        else
                        {
                            binaryTypeEnum = BinaryTypeEnum.ObjectUser;
                            Contract.Assert(objectInfo!=null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object"); 
                            assemId = (int)objectInfo.assemId;
                            if (assemId == 0) 
                                throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId",typeInformation)); 
                        }
                        break; 
                    default:
                        binaryTypeEnum = BinaryTypeEnum.Primitive;
                        typeInformation = primitiveTypeEnum;
                        break; 
                }
            } 
 
            SerTrace.Log( "BinaryConverter", "GetBinaryTypeInfo Exit ",((Enum)binaryTypeEnum).ToString(),", typeInformation ",typeInformation," assemId ",assemId);
            return binaryTypeEnum; 
        }
開發者ID:wsky,項目名稱:System.Runtime.Remoting,代碼行數:66,代碼來源:BinaryCommonClasses.cs

示例8: WriteJaggedArray

 internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
 {
     BinaryArrayTypeEnum jagged;
     this.InternalWriteItemNull();
     int[] lengthA = new int[] { length };
     int[] lowerBoundA = null;
     object typeInformation = null;
     int assemId = 0;
     if (lowerBound == 0)
     {
         jagged = BinaryArrayTypeEnum.Jagged;
     }
     else
     {
         jagged = BinaryArrayTypeEnum.JaggedOffset;
         lowerBoundA = new int[] { lowerBound };
     }
     BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out assemId);
     if (this.binaryArray == null)
     {
         this.binaryArray = new BinaryArray();
     }
     this.binaryArray.Set((int) arrayNameInfo.NIobjectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, jagged, assemId);
     long nIobjectId = arrayNameInfo.NIobjectId;
     this.binaryArray.Write(this);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:__BinaryWriter.cs

示例9: WriteArray

        [System.Security.SecurityCritical]  // auto-generated
        private void WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)          
        {
            SerTrace.Log( this, "WriteArray Entry ",objectInfo.obj," ",objectInfo.objectId);

            bool isAllocatedMemberNameInfo = false;
            if (memberNameInfo == null)
            {
                memberNameInfo = TypeToNameInfo(objectInfo);
                isAllocatedMemberNameInfo = true;
            }

            memberNameInfo.NIisArray = true;

            long objectId = objectInfo.objectId;
            memberNameInfo.NIobjectId = objectInfo.objectId;

            // Get array type
            System.Array array = (System.Array)objectInfo.obj;
            //Type arrayType = array.GetType();
            Type arrayType = objectInfo.objectType;         

            // Get type of array element 
            Type arrayElemType = arrayType.GetElementType();
            WriteObjectInfo arrayElemObjectInfo = null;
            if (!arrayElemType.IsPrimitive)
            {
                arrayElemObjectInfo = WriteObjectInfo.Serialize(arrayElemType, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, m_binder);
                arrayElemObjectInfo.assemId = GetAssemblyId(arrayElemObjectInfo);
            }


            NameInfo arrayElemTypeNameInfo = null;
            if (arrayElemObjectInfo == null)
                arrayElemTypeNameInfo = TypeToNameInfo(arrayElemType);
            else
                arrayElemTypeNameInfo = TypeToNameInfo(arrayElemObjectInfo);
            arrayElemTypeNameInfo.NIisArray = arrayElemTypeNameInfo.NItype.IsArray;

            NameInfo arrayNameInfo = memberNameInfo;
            arrayNameInfo.NIobjectId = objectId;
            arrayNameInfo.NIisArray = true;
            arrayElemTypeNameInfo.NIobjectId = objectId;
            arrayElemTypeNameInfo.NItransmitTypeOnMember = memberNameInfo.NItransmitTypeOnMember;
            arrayElemTypeNameInfo.NItransmitTypeOnObject = memberNameInfo.NItransmitTypeOnObject;
            arrayElemTypeNameInfo.NIisParentTypeOnObject = memberNameInfo.NIisParentTypeOnObject;

            // Get rank and length information
            int rank = array.Rank;
            int[] lengthA = new int[rank];
            int[] lowerBoundA = new int[rank];
            int[] upperBoundA = new int[rank];                  
            for (int i=0; i<rank; i++)
            {
                lengthA[i] = array.GetLength(i);
                lowerBoundA[i] = array.GetLowerBound(i);
                upperBoundA[i] = array.GetUpperBound(i);                            
            }

            InternalArrayTypeE arrayEnum;

            if (arrayElemTypeNameInfo.NIisArray)
            {
                if (rank == 1)
                    arrayEnum = InternalArrayTypeE.Jagged;
                else
                    arrayEnum = InternalArrayTypeE.Rectangular;
            }
            else if (rank == 1)
                arrayEnum = InternalArrayTypeE.Single;
            else
                arrayEnum = InternalArrayTypeE.Rectangular;

            arrayElemTypeNameInfo.NIarrayEnum = arrayEnum;

            SerTrace.Log( this, "WriteArray ArrayInfo type ",arrayType," rank ",rank);


            // Byte array
            if ((Object.ReferenceEquals(arrayElemType, Converter.typeofByte)) && (rank == 1) && (lowerBoundA[0] == 0))
            {
                serWriter.WriteObjectByteArray(memberNameInfo, arrayNameInfo, arrayElemObjectInfo, arrayElemTypeNameInfo, lengthA[0], lowerBoundA[0], (byte[])array);
                return;
            }

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

            if (CheckTypeFormat(formatterEnums.FEtypeFormat, FormatterTypeStyle.TypesAlways))
            {
                memberNameInfo.NItransmitTypeOnObject = true;
                arrayElemTypeNameInfo.NItransmitTypeOnObject = true;                
            }

            if (arrayEnum == InternalArrayTypeE.Single)
            {
                // Single Dimensional array
//.........這裏部分代碼省略.........
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:101,代碼來源:BinaryObjectWriter.cs

示例10: PutObjectInfo

 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
     //SerTrace.Log( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");
 }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:5,代碼來源:BinaryObjectInfo.cs

示例11: TypeToNameInfo

 private NameInfo TypeToNameInfo(WriteObjectInfo objectInfo, NameInfo nameInfo)
 {
     return TypeToNameInfo(objectInfo.objectType, objectInfo, ToCode(objectInfo.objectType), nameInfo);
 }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:4,代碼來源:BinaryObjectWriter.cs

示例12: WriteSingleArray

 internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
 {
     BinaryArrayTypeEnum single;
     int num;
     this.InternalWriteItemNull();
     int[] lengthA = new int[] { length };
     int[] lowerBoundA = null;
     object typeInformation = null;
     if (lowerBound == 0)
     {
         single = BinaryArrayTypeEnum.Single;
     }
     else
     {
         single = BinaryArrayTypeEnum.SingleOffset;
         lowerBoundA = new int[] { lowerBound };
     }
     BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out num);
     if (this.binaryArray == null)
     {
         this.binaryArray = new BinaryArray();
     }
     this.binaryArray.Set((int) arrayNameInfo.NIobjectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, single, num);
     long nIobjectId = arrayNameInfo.NIobjectId;
     this.binaryArray.Write(this);
     if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBound == 0))
     {
         if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Byte)
         {
             this.WriteBytes((byte[]) array);
         }
         else if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Char)
         {
             this.WriteChars((char[]) array);
         }
         else
         {
             this.WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo.NIprimitiveTypeEnum));
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:41,代碼來源:__BinaryWriter.cs

示例13: GetObjectInfo

        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo objectInfo = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                objectInfo.InternalInit();
                //SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
            }
            else
            {
                objectInfo = new WriteObjectInfo();
                objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;
                //SerTrace.Log( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");
            }

            return objectInfo;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:19,代碼來源:BinaryObjectInfo.cs

示例14: WriteRectangleArray

 internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
 {
     this.InternalWriteItemNull();
     BinaryArrayTypeEnum rectangular = BinaryArrayTypeEnum.Rectangular;
     object typeInformation = null;
     int assemId = 0;
     BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, this.objectWriter, out typeInformation, out assemId);
     if (this.binaryArray == null)
     {
         this.binaryArray = new BinaryArray();
     }
     for (int i = 0; i < rank; i++)
     {
         if (lowerBoundA[i] != 0)
         {
             rectangular = BinaryArrayTypeEnum.RectangularOffset;
             break;
         }
     }
     this.binaryArray.Set((int) arrayNameInfo.NIobjectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, rectangular, assemId);
     long nIobjectId = arrayNameInfo.NIobjectId;
     this.binaryArray.Write(this);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:23,代碼來源:__BinaryWriter.cs

示例15: WriteObjectByteArray

 internal void WriteObjectByteArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, byte[] byteA)
 {
     this.InternalWriteItemNull();
     this.WriteSingleArray(memberNameInfo, arrayNameInfo, objectInfo, arrayElemTypeNameInfo, length, lowerBound, byteA);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:5,代碼來源:__BinaryWriter.cs


注:本文中的System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。