Example #1
0
        // Reads the type information from the wire
        internal static object ReadTypeInfo(BinaryTypeEnum binaryTypeEnum, BinaryParser input, out int assemId)
        {
            object var         = null !;
            int    readAssemId = 0;

            switch (binaryTypeEnum)
            {
            case BinaryTypeEnum.Primitive:
            case BinaryTypeEnum.PrimitiveArray:
                var = (InternalPrimitiveTypeE)input.ReadByte();
                break;

            case BinaryTypeEnum.String:
            case BinaryTypeEnum.Object:
            case BinaryTypeEnum.StringArray:
            case BinaryTypeEnum.ObjectArray:
                break;

            case BinaryTypeEnum.ObjectUrt:
                var = input.ReadString();
                break;

            case BinaryTypeEnum.ObjectUser:
                var         = input.ReadString();
                readAssemId = input.ReadInt32();
                break;

            default:
                throw new SerializationException(SR.Format(SR.Serialization_TypeRead, binaryTypeEnum.ToString()));
            }
            assemId = readAssemId;
            return(var);
        }
Example #2
0
        public void Read(BinaryParser input)
        {
            // binaryHeaderEnum has already been read
            _objectId         = input.ReadInt32();
            _name             = input.ReadString();
            _numMembers       = input.ReadInt32();
            _memberNames      = new string[_numMembers];
            _binaryTypeEnumA  = new BinaryTypeEnum[_numMembers];
            _typeInformationA = new object[_numMembers];
            _memberAssemIds   = new int[_numMembers];
            for (int i = 0; i < _numMembers; i++)
            {
                _memberNames[i] = input.ReadString();
            }
            for (int i = 0; i < _numMembers; i++)
            {
                _binaryTypeEnumA[i] = (BinaryTypeEnum)input.ReadByte();
            }
            for (int i = 0; i < _numMembers; i++)
            {
                if (_binaryTypeEnumA[i] != BinaryTypeEnum.ObjectUrt && _binaryTypeEnumA[i] != BinaryTypeEnum.ObjectUser)
                {
                    _typeInformationA[i] = BinaryTypeConverter.ReadTypeInfo(_binaryTypeEnumA[i], input, out _memberAssemIds[i]);
                }
                else
                {
                    BinaryTypeConverter.ReadTypeInfo(_binaryTypeEnumA[i], input, out _memberAssemIds[i]);
                }
            }

            if (_binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId)
            {
                _assemId = input.ReadInt32();
            }
        }
Example #3
0
        public void Read(BinaryParser input)
        {
            switch (_binaryHeaderEnum)
            {
            case BinaryHeaderEnum.ArraySinglePrimitive:
                _objectId            = input.ReadInt32();
                _lengthA             = new int[1];
                _lengthA[0]          = input.ReadInt32();
                _binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
                _rank            = 1;
                _lowerBoundA     = new int[_rank];
                _binaryTypeEnum  = BinaryTypeEnum.Primitive;
                _typeInformation = (InternalPrimitiveTypeE)input.ReadByte();
                break;

            case BinaryHeaderEnum.ArraySingleString:
                _objectId            = input.ReadInt32();
                _lengthA             = new int[1];
                _lengthA[0]          = input.ReadInt32();
                _binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
                _rank            = 1;
                _lowerBoundA     = new int[_rank];
                _binaryTypeEnum  = BinaryTypeEnum.String;
                _typeInformation = null;
                break;

            case BinaryHeaderEnum.ArraySingleObject:
                _objectId            = input.ReadInt32();
                _lengthA             = new int[1];
                _lengthA[0]          = input.ReadInt32();
                _binaryArrayTypeEnum = BinaryArrayTypeEnum.Single;
                _rank            = 1;
                _lowerBoundA     = new int[_rank];
                _binaryTypeEnum  = BinaryTypeEnum.Object;
                _typeInformation = null;
                break;

            default:
                _objectId            = input.ReadInt32();
                _binaryArrayTypeEnum = (BinaryArrayTypeEnum)input.ReadByte();
                _rank        = input.ReadInt32();
                _lengthA     = new int[_rank];
                _lowerBoundA = new int[_rank];
                for (int i = 0; i < _rank; i++)
                {
                    _lengthA[i] = input.ReadInt32();
                }
                if ((_binaryArrayTypeEnum == BinaryArrayTypeEnum.SingleOffset) ||
                    (_binaryArrayTypeEnum == BinaryArrayTypeEnum.JaggedOffset) ||
                    (_binaryArrayTypeEnum == BinaryArrayTypeEnum.RectangularOffset))
                {
                    for (int i = 0; i < _rank; i++)
                    {
                        _lowerBoundA[i] = input.ReadInt32();
                    }
                }
                _binaryTypeEnum  = (BinaryTypeEnum)input.ReadByte();
                _typeInformation = BinaryTypeConverter.ReadTypeInfo(_binaryTypeEnum, input, out _assemId);
                break;
            }
        }
Example #4
0
        // Reads the type information from the wire
        internal static object ReadTypeInfo(BinaryTypeEnum binaryTypeEnum, BinaryParser input, out int assemId)
        {
            object var = null;
            int readAssemId = 0;

            switch (binaryTypeEnum)
            {
                case BinaryTypeEnum.Primitive:
                case BinaryTypeEnum.PrimitiveArray:
                    var = (InternalPrimitiveTypeE)input.ReadByte();
                    break;
                case BinaryTypeEnum.String:
                case BinaryTypeEnum.Object:
                case BinaryTypeEnum.StringArray:
                case BinaryTypeEnum.ObjectArray:
                    break;
                case BinaryTypeEnum.ObjectUrt:
                    var = input.ReadString();
                    break;
                case BinaryTypeEnum.ObjectUser:
                    var = input.ReadString();
                    readAssemId = input.ReadInt32();
                    break;
                default:
                    throw new SerializationException(SR.Format(SR.Serialization_TypeRead, binaryTypeEnum.ToString()));
            }
            assemId = readAssemId;
            return var;
        }