Пример #1
0
        internal void WriteRectangleArray(/*NameInfo memberNameInfo,*/ NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int rank, int[] lengthA, int[] lowerBoundA)
        {
            this.InternalWriteItemNull();
            BinaryArrayTypeEnum rectangular    = BinaryArrayTypeEnum.Rectangular;
            BinaryTypeEnum      binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type, objectInfo, this._objectWriter, out object typeInformation, out int assemId);

            if (this._binaryArray == null)
            {
                this._binaryArray = new BinaryArray();
            }
            int index = 0;

            while (true)
            {
                if (index < rank)
                {
                    if (lowerBoundA[index] == 0)
                    {
                        index++;
                        continue;
                    }
                    rectangular = BinaryArrayTypeEnum.RectangularOffset;
                }
                this._binaryArray.Set((int)arrayNameInfo._objectId, rank, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, rectangular, assemId);
                this._binaryArray.Write(this);
                return;
            }
        }
Пример #2
0
        internal void WriteJaggedArray(NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound)
        {
            BinaryArrayTypeEnum jagged;

            this.InternalWriteItemNull();
            int[] lengthA     = new int[] { length };
            int[] lowerBoundA = null;
            if (lowerBound == 0)
            {
                jagged = BinaryArrayTypeEnum.Jagged;
            }
            else
            {
                jagged      = BinaryArrayTypeEnum.JaggedOffset;
                lowerBoundA = new int[] { lowerBound };
            }
            BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type, objectInfo, _objectWriter, out object typeInformation, out int assemId);

            if (this._binaryArray == null)
            {
                this._binaryArray = new BinaryArray();
            }
            this._binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, jagged, assemId);
            this._binaryArray.Write(this);
        }
Пример #3
0
        internal void WriteSingleArray(/*NameInfo memberNameInfo,*/ NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, int length, int lowerBound, Array array)
        {
            BinaryArrayTypeEnum single;

            this.InternalWriteItemNull();
            int[] lengthA     = new int[] { length };
            int[] lowerBoundA = null;
            if (lowerBound == 0)
            {
                single = BinaryArrayTypeEnum.Single;
            }
            else
            {
                single      = BinaryArrayTypeEnum.SingleOffset;
                lowerBoundA = new int[] { lowerBound };
            }
            BinaryTypeEnum binaryTypeEnum = BinaryTypeConverter.GetBinaryTypeInfo(arrayElemTypeNameInfo._type, objectInfo, this._objectWriter, out object typeInformation, out int num);

            if (this._binaryArray == null)
            {
                this._binaryArray = new BinaryArray();
            }
            this._binaryArray.Set((int)arrayNameInfo._objectId, 1, lengthA, lowerBoundA, binaryTypeEnum, typeInformation, single, num);
            this._binaryArray.Write(this);
            if (Converter.IsWriteAsByteArray(arrayElemTypeNameInfo._primitiveTypeEnum) && (lowerBound == 0))
            {
                if (arrayElemTypeNameInfo._primitiveTypeEnum == PrimitiveTypeEnum.Byte)
                {
                    this.Write((byte[])array);
                }
                else if (arrayElemTypeNameInfo._primitiveTypeEnum == PrimitiveTypeEnum.Char)
                {
                    this.Write((char[])array);
                }
                else
                {
                    this.WriteArrayAsBytes(array, Converter.TypeLength(arrayElemTypeNameInfo._primitiveTypeEnum));
                }
            }
        }
Пример #4
0
        internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos)
        {
            string str;

            this.InternalWriteItemNull();
            int objectId = (int)nameInfo._objectId;

            str = (objectId < 0) ? typeNameInfo.NIname : nameInfo.NIname;
            if (this._objectMapTable == null)
            {
                this._objectMapTable = new Dictionary <string, ObjectMapInfo>();
            }
            if (this._objectMapTable.TryGetValue(str, out ObjectMapInfo info) && info.IsCompatible(numMembers, memberNames, memberTypes))
            {
                if (this._binaryObject == null)
                {
                    this._binaryObject = new BinaryObject();
                }
                this._binaryObject.Set(objectId, info._objectId);
                this._binaryObject.Write(this);
            }
            else
            {
                int num;
                if (!typeNameInfo._transmitTypeOnObject)
                {
                    if (this._binaryObjectWithMap == null)
                    {
                        this._binaryObjectWithMap = new BinaryObjectWithMap();
                    }
                    num = (int)typeNameInfo._assemId;
                    this._binaryObjectWithMap.Set(objectId, str, numMembers, memberNames, num);
                    this._binaryObjectWithMap.Write(this);
                    if (info == null)
                    {
                        this._objectMapTable.Add(str, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                    }
                }
                else
                {
                    BinaryTypeEnum[] binaryTypeEnumA  = new BinaryTypeEnum[numMembers];
                    object[]         typeInformationA = new object[numMembers];
                    int[]            memberAssemIds   = new int[numMembers];
                    int index = 0;
                    while (true)
                    {
                        if (index >= numMembers)
                        {
                            if (this._binaryObjectWithMapTyped == null)
                            {
                                this._binaryObjectWithMapTyped = new BinaryObjectWithMapTyped();
                            }
                            this._binaryObjectWithMapTyped.Set(objectId, str, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, (int)typeNameInfo._assemId);
                            this._binaryObjectWithMapTyped.Write(this);
                            if (info == null)
                            {
                                this._objectMapTable.Add(str, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes));
                            }
                            break;
                        }
                        binaryTypeEnumA[index]  = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[index], memberObjectInfos[index], this._objectWriter, out object typeInformation, out num);
                        typeInformationA[index] = typeInformation;
                        memberAssemIds[index]   = num;
                        index++;
                    }
                }
            }
        }