示例#1
0
        public void Write(BinaryFormatterWriter output)
        {
            Debug.Assert(_name != null && _memberNames != null && _binaryTypeEnumA != null && _typeInformationA != null && _memberAssemIds != null);
            output.WriteByte((byte)_binaryHeaderEnum);
            output.WriteInt32(_objectId);
            output.WriteString(_name);

            output.WriteInt32(_numMembers);
            for (int i = 0; i < _numMembers; i++)
            {
                output.WriteString(_memberNames[i]);
            }
            for (int i = 0; i < _numMembers; i++)
            {
                output.WriteByte((byte)_binaryTypeEnumA[i]);
            }
            for (int i = 0; i < _numMembers; i++)
            {
                BinaryTypeConverter.WriteTypeInfo(_binaryTypeEnumA[i], _typeInformationA[i], _memberAssemIds[i], output);
            }

            if (_assemId > 0)
            {
                output.WriteInt32(_assemId);
            }
        }
示例#2
0
        // Writes the type information on the wire
        internal static void WriteTypeInfo(BinaryTypeEnum binaryTypeEnum, object?typeInformation, int assemId, BinaryFormatterWriter output)
        {
            switch (binaryTypeEnum)
            {
            case BinaryTypeEnum.Primitive:
            case BinaryTypeEnum.PrimitiveArray:
                Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
                output.WriteByte((byte)((InternalPrimitiveTypeE)typeInformation));
                break;

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

            case BinaryTypeEnum.ObjectUrt:
                Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
                output.WriteString(typeInformation.ToString() !);
                break;

            case BinaryTypeEnum.ObjectUser:
                Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
                output.WriteString(typeInformation.ToString() !);
                output.WriteInt32(assemId);
                break;

            default:
                throw new SerializationException(SR.Format(SR.Serialization_TypeWrite, binaryTypeEnum.ToString()));
            }
        }
示例#3
0
 public void Write(BinaryFormatterWriter output)
 {
     output.WriteByte((byte)BinaryHeaderEnum.Assembly);
     output.WriteInt32(_assemId);
     Debug.Assert(_assemblyString != null);
     output.WriteString(_assemblyString);
 }
 public void Write(BinaryFormatterWriter output)
 {
     _majorVersion = BinaryFormatterMajorVersion;
     _minorVersion = BinaryFormatterMinorVersion;
     output.WriteByte((byte)_binaryHeaderEnum);
     output.WriteInt32(_topId);
     output.WriteInt32(_headerId);
     output.WriteInt32(BinaryFormatterMajorVersion);
     output.WriteInt32(BinaryFormatterMinorVersion);
 }
示例#5
0
 public void Write(BinaryFormatterWriter output)
 {
     _majorVersion = BinaryFormatterMajorVersion;
     _minorVersion = BinaryFormatterMinorVersion;
     output.WriteByte((byte)_binaryHeaderEnum);
     output.WriteInt32(_topId);
     output.WriteInt32(_headerId);
     output.WriteInt32(BinaryFormatterMajorVersion);
     output.WriteInt32(BinaryFormatterMinorVersion);
 }
示例#6
0
        public void Write(BinaryFormatterWriter output)
        {
            Debug.Assert(_name != null && _memberNames != null);
            output.WriteByte((byte)_binaryHeaderEnum);
            output.WriteInt32(_objectId);
            output.WriteString(_name);

            output.WriteInt32(_numMembers);
            for (int i = 0; i < _numMembers; i++)
            {
                output.WriteString(_memberNames[i]);
            }

            if (_assemId > 0)
            {
                output.WriteInt32(_assemId);
            }
        }
示例#7
0
        public void Write(BinaryFormatterWriter output)
        {
            Debug.Assert(_lengthA != null);
            switch (_binaryHeaderEnum)
            {
            case BinaryHeaderEnum.ArraySinglePrimitive:
                output.WriteByte((byte)_binaryHeaderEnum);
                output.WriteInt32(_objectId);
                output.WriteInt32(_lengthA[0]);
                output.WriteByte((byte)((InternalPrimitiveTypeE)_typeInformation !));
                break;

            case BinaryHeaderEnum.ArraySingleString:
                output.WriteByte((byte)_binaryHeaderEnum);
                output.WriteInt32(_objectId);
                output.WriteInt32(_lengthA[0]);
                break;

            case BinaryHeaderEnum.ArraySingleObject:
                output.WriteByte((byte)_binaryHeaderEnum);
                output.WriteInt32(_objectId);
                output.WriteInt32(_lengthA[0]);
                break;

            default:
                output.WriteByte((byte)_binaryHeaderEnum);
                output.WriteInt32(_objectId);
                output.WriteByte((byte)_binaryArrayTypeEnum);
                output.WriteInt32(_rank);
                for (int i = 0; i < _rank; i++)
                {
                    output.WriteInt32(_lengthA[i]);
                }
                if ((_binaryArrayTypeEnum == BinaryArrayTypeEnum.SingleOffset) ||
                    (_binaryArrayTypeEnum == BinaryArrayTypeEnum.JaggedOffset) ||
                    (_binaryArrayTypeEnum == BinaryArrayTypeEnum.RectangularOffset))
                {
                    Debug.Assert(_lowerBoundA != null);
                    for (int i = 0; i < _rank; i++)
                    {
                        output.WriteInt32(_lowerBoundA[i]);
                    }
                }
                output.WriteByte((byte)_binaryTypeEnum);
                BinaryTypeConverter.WriteTypeInfo(_binaryTypeEnum, _typeInformation, _assemId, output);
                break;
            }
        }
示例#8
0
 // Writes the type information on the wire
 internal static void WriteTypeInfo(BinaryTypeEnum binaryTypeEnum, object typeInformation, int assemId, BinaryFormatterWriter output)
 {
     switch (binaryTypeEnum)
     {
         case BinaryTypeEnum.Primitive:
         case BinaryTypeEnum.PrimitiveArray:
             Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
             output.WriteByte((byte)((InternalPrimitiveTypeE)typeInformation));
             break;
         case BinaryTypeEnum.String:
         case BinaryTypeEnum.Object:
         case BinaryTypeEnum.StringArray:
         case BinaryTypeEnum.ObjectArray:
             break;
         case BinaryTypeEnum.ObjectUrt:
             Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
             output.WriteString(typeInformation.ToString());
             break;
         case BinaryTypeEnum.ObjectUser:
             Debug.Assert(typeInformation != null, "[BinaryConverter.WriteTypeInfo]typeInformation!=null");
             output.WriteString(typeInformation.ToString());
             output.WriteInt32(assemId);
             break;
         default:
             throw new SerializationException(SR.Format(SR.Serialization_TypeWrite, binaryTypeEnum.ToString()));
     }
 }