GetBinaryTypeInfo() 정적인 개인적인 메소드

static private GetBinaryTypeInfo ( Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, object &typeInformation, int &assemId ) : BinaryTypeEnum
type Type
objectInfo WriteObjectInfo
typeName string
objectWriter ObjectWriter
typeInformation object
assemId int
리턴 BinaryTypeEnum
예제 #1
0
        internal void WriteRectangleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
        {
            InternalWriteItemNull();

            BinaryArrayTypeEnum binaryArrayTypeEnum = BinaryArrayTypeEnum.Rectangular;
            object         typeInformation          = null;
            int            assemId        = 0;
            BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type, 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._objectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, binaryArrayTypeEnum, assemId);
            _binaryArray.Write(this);
        }
예제 #2
0
        internal void WriteJaggedArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
        {
            InternalWriteItemNull();
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            var lengthA = new int[1];

            lengthA[0] = length;
            int[]  lowerBoundA     = null;
            object typeInformation = null;
            int    assemId         = 0;

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

            BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId);

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

            _binaryArray.Write(this);
        }
예제 #3
0
        internal void WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
        {
            InternalWriteItemNull();
            BinaryArrayTypeEnum binaryArrayTypeEnum;
            var lengthA = new int[1];

            lengthA[0] = length;
            int[]  lowerBoundA     = null;
            object typeInformation = null;

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

            int            assemId;
            BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(
                arrayElemTypeNameInfo._type, objectInfo, arrayElemTypeNameInfo.NIname, _objectWriter, out typeInformation, out assemId);

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

            _binaryArray.Write(this);

            if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo._primitiveTypeEnum) && (lowerBound == 0))
            {
                //array is written out as an array of bytes
                if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Byte)
                {
                    WriteBytes((byte[])array);
                }
                else if (arrayElemTypeNameInfo._primitiveTypeEnum == InternalPrimitiveTypeE.Char)
                {
                    WriteChars((char[])array);
                }
                else
                {
                    WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo._primitiveTypeEnum));
                }
            }
        }
예제 #4
0
        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            InternalWriteItemNull();
            int assemId;
            int objectId = (int)nameInfo._objectId;

            string objectName = objectId < 0 ?
                                objectName = typeNameInfo.NIname :         // Nested Object
                                             objectName = nameInfo.NIname; // Non-Nested

            if (_objectMapTable == null)
            {
                _objectMapTable = new Dictionary <string, ObjectMapInfo>();
            }

            ObjectMapInfo objectMapInfo;

            if (_objectMapTable.TryGetValue(objectName, out objectMapInfo) &&
                objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes))
            {
                // Object
                if (_binaryObject == null)
                {
                    _binaryObject = new BinaryObject();
                }

                _binaryObject.Set(objectId, objectMapInfo._objectId);
                _binaryObject.Write(this);
            }
            else if (!typeNameInfo._transmitTypeOnObject)
            {
                // ObjectWithMap
                if (_binaryObjectWithMap == null)
                {
                    _binaryObjectWithMap = new BinaryObjectWithMap();
                }

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

                _binaryObjectWithMap.Write(this);
                if (objectMapInfo == null)
                {
                    _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
            else
            {
                // ObjectWithMapTyped
                var binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                var typeInformationA = new object[numMembers];
                var assemIdA         = new int[numMembers];
                for (int i = 0; i < numMembers; i++)
                {
                    object typeInformation = null;
                    binaryTypeEnumA[i]  = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId);
                    typeInformationA[i] = typeInformation;
                    assemIdA[i]         = assemId;
                }

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

                // BCL types are not placed in table
                assemId = (int)typeNameInfo._assemId;
                _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId);
                _binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
        }
예제 #5
0
        internal void WriteObject(NameInfo nameInfo, NameInfo?typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            InternalWriteItemNull();
            int assemId;
            int objectId = (int)nameInfo._objectId;

            Debug.Assert(typeNameInfo != null);       // Explicitly called with null. Potential bug, but closed as Won't Fix: https://github.com/dotnet/runtime/issues/31402
            string?objectName = objectId < 0 ?
                                typeNameInfo.NIname : // Nested Object
                                nameInfo.NIname;      // Non-Nested

            if (_objectMapTable == null)
            {
                _objectMapTable = new Dictionary <string, ObjectMapInfo>();
            }

            Debug.Assert(objectName != null);
            if (_objectMapTable.TryGetValue(objectName, out ObjectMapInfo? objectMapInfo) &&
                objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes))
            {
                // Object
                if (_binaryObject == null)
                {
                    _binaryObject = new BinaryObject();
                }

                _binaryObject.Set(objectId, objectMapInfo._objectId);
                _binaryObject.Write(this);
            }
            else if (!typeNameInfo._transmitTypeOnObject)
            {
                // ObjectWithMap
                if (_binaryObjectWithMap == null)
                {
                    _binaryObjectWithMap = new BinaryObjectWithMap();
                }

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

                _binaryObjectWithMap.Write(this);
                if (objectMapInfo == null)
                {
                    _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
            else
            {
                // ObjectWithMapTyped
                var binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                var typeInformationA = new object?[numMembers];
                var assemIdA         = new int[numMembers];
                for (int i = 0; i < numMembers; i++)
                {
                    object?typeInformation;
                    binaryTypeEnumA[i]  = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId);
                    typeInformationA[i] = typeInformation;
                    assemIdA[i]         = assemId;
                }

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

                // BCL types are not placed in table
                assemId = (int)typeNameInfo._assemId;
                _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId);
                _binaryObjectWithMapTyped.Write(this);
                if (objectMapInfo == null)
                {
                    _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                }
            }
        }