GetBinaryTypeInfo() static private méthode

static private GetBinaryTypeInfo ( Type type, WriteObjectInfo objectInfo, String typeName, ObjectWriter objectWriter, Object &typeInformation, int &assemId ) : BinaryTypeEnum
type System.Type
objectInfo WriteObjectInfo
typeName String
objectWriter ObjectWriter
typeInformation Object
assemId int
Résultat BinaryTypeEnum
        internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
        {
            InternalWriteItemNull();
#if _DEBUG
            arrayNameInfo.Dump("WriteSingleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteSingleArray arrayElemTypeNameInfo");
#endif
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            Int32[]             lengthA = new Int32[1];
            lengthA[0] = length;
            Int32[] lowerBoundA     = null;
            Object  typeInformation = null;

            if (lowerBound == 0)
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
            }
            else
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.SingleOffset;
                lowerBoundA         = new Int32[1];
                lowerBoundA[0]      = lowerBound;
            }

            int assemId;

            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }
            binaryArray.Set((int)arrayNameInfo.NIobjectId, (int)1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);

            if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && (lowerBound == 0))
            {
                //array is written out as an array of bytes
                if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Byte)
                {
                    WriteBytes((Byte[])array);
                }
                else if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Char)
                {
                    WriteChars((char[])array);
                }
                else
                {
                    WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo.NIprimitiveTypeEnum));
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
        internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
        {
            this.InternalWriteItemNull();
            int[] lengthA = new int[]
            {
                length
            };
            int[]  lowerBoundA     = null;
            object typeInformation = null;
            BinaryArrayTypeEnum binaryArrayTypeEnum;

            if (lowerBound == 0)
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
            }
            else
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.SingleOffset;
                lowerBoundA         = new int[]
                {
                    lowerBound
                };
            }
            int            assemId;
            BinaryTypeEnum binaryTypeInfo = 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, binaryTypeInfo, typeInformation, binaryArrayTypeEnum, assemId);
            long niobjectId = arrayNameInfo.NIobjectId;

            this.binaryArray.Write(this);
            if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo.NIprimitiveTypeEnum) && lowerBound == 0)
            {
                if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Byte)
                {
                    this.WriteBytes((byte[])array);
                    return;
                }
                if (arrayElemTypeNameInfo.NIprimitiveTypeEnum == InternalPrimitiveTypeE.Char)
                {
                    this.WriteChars((char[])array);
                    return;
                }
                this.WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo.NIprimitiveTypeEnum));
            }
        }
        internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
        {
#if _DEBUG
            arrayNameInfo.Dump("WriteRectangleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteRectangleArray arrayElemTypeNameInfo");
#endif
            InternalWriteItemNull();
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            Int32[]             lengthA = new Int32[1];
            lengthA[0] = length;
            Int32[] lowerBoundA     = null;
            Object  typeInformation = null;
            int     assemId         = 0;

            if (lowerBound == 0)
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.Jagged;
            }
            else
            {
                binaryArrayTypeEnum = BinaryArrayTypeEnum.JaggedOffset;
                lowerBoundA         = new Int32[1];
                lowerBoundA[0]      = lowerBound;
            }

            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }
            binaryArray.Set((int)arrayNameInfo.NIobjectId, (int)1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);
        }
        internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
        {
#if _DEBUG
            arrayNameInfo.Dump("WriteRectangleArray arrayNameInfo");
            arrayElemTypeNameInfo.Dump("WriteRectangleArray arrayElemTypeNameInfo");
#endif
            InternalWriteItemNull();

            BinaryArrayTypeEnum binaryArrayTypeEnum = BinaryArrayTypeEnum.Rectangular;
            Object         typeInformation          = null;
            int            assemId        = 0;
            BinaryTypeEnum binaryTypeEnum = BinaryConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo.NItype, objectInfo, arrayElemTypeNameInfo.NIname, objectWriter, out typeInformation, out assemId);

            if (binaryArray == null)
            {
                binaryArray = new BinaryArray();
            }

            for (int i = 0; i < rank; i++)
            {
                if (lowerBoundA[i] != 0)
                {
                    binaryArrayTypeEnum = BinaryArrayTypeEnum.RectangularOffset;
                    break;
                }
            }

            binaryArray.Set((int)arrayNameInfo.NIobjectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);

            if (arrayNameInfo.NIobjectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }
#if _DEBUG
            binaryArray.Dump();
#endif
            binaryArray.Write(this);
        }
        //internal BinaryCrossAppDomainMap crossAppDomainMap;

        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, String[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            InternalWriteItemNull();
            int assemId;

            nameInfo.Dump("WriteObject nameInfo");
            typeNameInfo.Dump("WriteObject typeNameInfo");

            int objectId = (int)nameInfo.NIobjectId;

            //if (objectId < 0)
            //	objectId = --m_nestedObjectCount;

            if (objectId > 0)
            {
                BCLDebug.Trace("BINARY", "-----Top Level Object-----");
            }

            String objectName = null;

            if (objectId < 0)
            {
                // Nested Object
                objectName = typeNameInfo.NIname;
            }
            else
            {
                // Non-Nested
                objectName = nameInfo.NIname;
            }
            SerTrace.Log(this, "WriteObject objectName ", objectName);

            if (objectMapTable == null)
            {
                objectMapTable = new Hashtable();
            }

            ObjectMapInfo objectMapInfo = (ObjectMapInfo)objectMapTable[objectName];

            if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes))
            {
                // Object
                if (binaryObject == null)
                {
                    binaryObject = new BinaryObject();
                }
                binaryObject.Set(objectId, objectMapInfo.objectId);
                binaryObject.Dump();
                binaryObject.Write(this);
            }
            else if (!typeNameInfo.NItransmitTypeOnObject)
            {
                // ObjectWithMap
                if (binaryObjectWithMap == null)
                {
                    binaryObjectWithMap = new BinaryObjectWithMap();
                }

                // BCL types are not placed into table
                assemId = (int)typeNameInfo.NIassemId;
                binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId);

                binaryObjectWithMap.Dump();
                binaryObjectWithMap.Write(this);
                if (objectMapInfo == null)
                {
                    objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
            else
            {
                // ObjectWithMapTyped
                BinaryTypeEnum[] binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                Object[]         typeInformationA = new Object[numMembers];
                int[]            assemIdA         = new int[numMembers];
                for (int i = 0; i < numMembers; i++)
                {
                    Object typeInformation = null;

                    binaryTypeEnumA[i]  = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, objectWriter, out typeInformation, out assemId);
                    typeInformationA[i] = typeInformation;
                    assemIdA[i]         = assemId;
                    SerTrace.Log(this, "WriteObject ObjectWithMapTyped memberNames "
                                 , memberNames[i], ", memberType ", memberTypes[i], " binaryTypeEnum ", ((Enum)binaryTypeEnumA[i]).ToString()
                                 , ", typeInformation ", typeInformationA[i], " assemId ", assemIdA[i]);
                }

                if (binaryObjectWithMapTyped == null)
                {
                    binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                }

                // BCL types are not placed in table
                assemId = (int)typeNameInfo.NIassemId;
                binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId);

                binaryObjectWithMapTyped.Dump();
                binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
        }
        // Token: 0x0600527F RID: 21119 RVA: 0x001215D0 File Offset: 0x0011F7D0
        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            this.InternalWriteItemNull();
            int    num = (int)nameInfo.NIobjectId;
            string niname;

            if (num < 0)
            {
                niname = typeNameInfo.NIname;
            }
            else
            {
                niname = nameInfo.NIname;
            }
            if (this.objectMapTable == null)
            {
                this.objectMapTable = new Hashtable();
            }
            ObjectMapInfo objectMapInfo = (ObjectMapInfo)this.objectMapTable[niname];

            if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes))
            {
                if (this.binaryObject == null)
                {
                    this.binaryObject = new BinaryObject();
                }
                this.binaryObject.Set(num, objectMapInfo.objectId);
                this.binaryObject.Write(this);
                return;
            }
            if (!typeNameInfo.NItransmitTypeOnObject)
            {
                if (this.binaryObjectWithMap == null)
                {
                    this.binaryObjectWithMap = new BinaryObjectWithMap();
                }
                int num2 = (int)typeNameInfo.NIassemId;
                this.binaryObjectWithMap.Set(num, niname, numMembers, memberNames, num2);
                this.binaryObjectWithMap.Dump();
                this.binaryObjectWithMap.Write(this);
                if (objectMapInfo == null)
                {
                    this.objectMapTable.Add(niname, new ObjectMapInfo(num, numMembers, memberNames, memberTypes));
                    return;
                }
            }
            else
            {
                BinaryTypeEnum[] array  = new BinaryTypeEnum[numMembers];
                object[]         array2 = new object[numMembers];
                int[]            array3 = new int[numMembers];
                int num2;
                for (int i = 0; i < numMembers; i++)
                {
                    object obj = null;
                    array[i]  = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, this.objectWriter, out obj, out num2);
                    array2[i] = obj;
                    array3[i] = num2;
                }
                if (this.binaryObjectWithMapTyped == null)
                {
                    this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                }
                num2 = (int)typeNameInfo.NIassemId;
                this.binaryObjectWithMapTyped.Set(num, niname, numMembers, memberNames, array, array2, array3, num2);
                this.binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    this.objectMapTable.Add(niname, new ObjectMapInfo(num, numMembers, memberNames, memberTypes));
                }
            }
        }
        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            this.InternalWriteItemNull();
            int    objectId = (int)nameInfo.NIobjectId;
            string name     = objectId >= 0 ? nameInfo.NIname : typeNameInfo.NIname;

            if (this.objectMapTable == null)
            {
                this.objectMapTable = new Hashtable();
            }
            ObjectMapInfo objectMapInfo = (ObjectMapInfo)this.objectMapTable[(object)name];

            if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes))
            {
                if (this.binaryObject == null)
                {
                    this.binaryObject = new BinaryObject();
                }
                this.binaryObject.Set(objectId, objectMapInfo.objectId);
                this.binaryObject.Write(this);
            }
            else if (!typeNameInfo.NItransmitTypeOnObject)
            {
                if (this.binaryObjectWithMap == null)
                {
                    this.binaryObjectWithMap = new BinaryObjectWithMap();
                }
                int assemId = (int)typeNameInfo.NIassemId;
                this.binaryObjectWithMap.Set(objectId, name, numMembers, memberNames, assemId);
                this.binaryObjectWithMap.Dump();
                this.binaryObjectWithMap.Write(this);
                if (objectMapInfo != null)
                {
                    return;
                }
                this.objectMapTable.Add((object)name, (object)new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
            }
            else
            {
                BinaryTypeEnum[] binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                object[]         typeInformationA = new object[numMembers];
                int[]            memberAssemIds   = new int[numMembers];
                int assemId;
                for (int index = 0; index < numMembers; ++index)
                {
                    object typeInformation = (object)null;
                    binaryTypeEnumA[index]  = BinaryConverter.GetBinaryTypeInfo(memberTypes[index], memberObjectInfos[index], (string)null, this.objectWriter, out typeInformation, out assemId);
                    typeInformationA[index] = typeInformation;
                    memberAssemIds[index]   = assemId;
                }
                if (this.binaryObjectWithMapTyped == null)
                {
                    this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                }
                assemId = (int)typeNameInfo.NIassemId;
                this.binaryObjectWithMapTyped.Set(objectId, name, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, assemId);
                this.binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo != null)
                {
                    return;
                }
                this.objectMapTable.Add((object)name, (object)new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
            }
        }
Exemple #10
0
        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            this.InternalWriteItemNull();
            int    nIobjectId = (int)nameInfo.NIobjectId;
            string name       = null;

            if (nIobjectId < 0)
            {
                name = typeNameInfo.NIname;
            }
            else
            {
                name = nameInfo.NIname;
            }
            if (this.objectMapTable == null)
            {
                this.objectMapTable = new Hashtable();
            }
            ObjectMapInfo info = (ObjectMapInfo)this.objectMapTable[name];

            if ((info != null) && info.isCompatible(numMembers, memberNames, memberTypes))
            {
                if (this.binaryObject == null)
                {
                    this.binaryObject = new BinaryObject();
                }
                this.binaryObject.Set(nIobjectId, info.objectId);
                this.binaryObject.Write(this);
            }
            else
            {
                int nIassemId;
                if (!typeNameInfo.NItransmitTypeOnObject)
                {
                    if (this.binaryObjectWithMap == null)
                    {
                        this.binaryObjectWithMap = new BinaryObjectWithMap();
                    }
                    nIassemId = (int)typeNameInfo.NIassemId;
                    this.binaryObjectWithMap.Set(nIobjectId, name, numMembers, memberNames, nIassemId);
                    this.binaryObjectWithMap.Dump();
                    this.binaryObjectWithMap.Write(this);
                    if (info == null)
                    {
                        this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes));
                    }
                }
                else
                {
                    BinaryTypeEnum[] binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                    object[]         typeInformationA = new object[numMembers];
                    int[]            memberAssemIds   = new int[numMembers];
                    for (int i = 0; i < numMembers; i++)
                    {
                        object typeInformation = null;
                        binaryTypeEnumA[i]  = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, this.objectWriter, out typeInformation, out nIassemId);
                        typeInformationA[i] = typeInformation;
                        memberAssemIds[i]   = nIassemId;
                    }
                    if (this.binaryObjectWithMapTyped == null)
                    {
                        this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                    }
                    nIassemId = (int)typeNameInfo.NIassemId;
                    this.binaryObjectWithMapTyped.Set(nIobjectId, name, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, nIassemId);
                    this.binaryObjectWithMapTyped.Write(this);
                    if (info == null)
                    {
                        this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes));
                    }
                }
            }
        }