コード例 #1
0
 internal void ReadObjectWithMap(BinaryHeaderEnum binaryHeaderEnum)
 {
     if (_bowm == null)
     {
         _bowm = new BinaryObjectWithMap(binaryHeaderEnum);
     }
     else
     {
         _bowm.BinaryHeaderEnum = binaryHeaderEnum;
     }
     _bowm.Read(this);
     ReadObjectWithMap(_bowm);
 }
コード例 #2
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++;
                    }
                }
            }
        }
コード例 #3
0
        private void ReadObjectWithMap(BinaryObjectWithMap record)
        {
            BinaryAssemblyInfo assemblyInfo = null;
            ObjectProgress     op           = GetOp();
            ParseRecord        pr           = op._pr;

            stack.Push(op);
            if (record.BinaryHeaderEnum != BinaryHeaderEnum.ObjectWithMapAssemId)
            {
                if (record.BinaryHeaderEnum == BinaryHeaderEnum.ObjectWithMap)
                {
                    assemblyInfo = SystemAssemblyInfo;
                }
            }
            else
            {
                if (record.AssemId < 1)
                {
                    throw new SerializationException(RemotingResources.SerializationAssemblyNotFound.Format(record.Name));
                }
                assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[record.AssemId];
                if (assemblyInfo == null)
                {
                    throw new SerializationException(RemotingResources.SerializationAssemblyNotFound.Format(record.AssemId.ToString() + " " + record.Name));
                }
            }
            Type      objectType = objectReader.GetType(assemblyInfo, record.Name);
            ObjectMap map        = ObjectMap.Create(record.Name, objectType, record.MemberNames, objectReader, record.ObjectId, assemblyInfo);

            ObjectMapIdTable[record.ObjectId] = map;
            op._objectTypeEnum   = ObjectTypeEnum.Object;
            op._binaryTypeEnumA  = map._binaryTypeEnumA;
            op._typeInformationA = map._typeInformationA;
            op._memberLength     = op._binaryTypeEnumA.Length;
            op._memberNames      = map._memberNames;
            op._memberTypes      = map._memberTypes;
            ObjectProgress progress2 = (ObjectProgress)stack.PeekPeek();

            if (progress2 == null || progress2._isInitial)
            {
                op._name            = record.Name;
                pr.parseTypeEnum    = ParseTypeEnum.Object;
                op._memberValueEnum = MemberValueEnum.Empty;
            }
            else
            {
                pr.parseTypeEnum    = ParseTypeEnum.Member;
                pr.memberValueEnum  = MemberValueEnum.Nested;
                op._memberValueEnum = MemberValueEnum.Nested;
                ObjectTypeEnum ee = progress2._objectTypeEnum;
                if (ee == ObjectTypeEnum.Object)
                {
                    pr.name            = progress2._name;
                    pr.memberTypeEnum  = MemberTypeEnum.Field;
                    op._memberTypeEnum = MemberTypeEnum.Field;
                }
                else
                {
                    if (ee != ObjectTypeEnum.Array)
                    {
                        throw new SerializationException(RemotingResources.SerializationObjectTypeEnum.Format(progress2._objectTypeEnum.ToString()));
                    }
                    pr.memberTypeEnum  = MemberTypeEnum.Item;
                    op._memberTypeEnum = MemberTypeEnum.Field;
                }
            }
            pr.objectTypeEnum = ObjectTypeEnum.Object;
            pr.objectId       = objectReader.GetId((long)record.ObjectId);
            pr.objectInfo     = map.CreateObjectInfo(ref pr.si, ref pr.memberData);
            if (pr.objectId == topId)
            {
                pr.objectPositionEnum = ObjectPositionEnum.Top;
            }
            pr.keyDt      = record.Name;
            pr.dtType     = map._objectType;
            pr.dtTypeCode = PrimitiveTypeEnum.Invalid;
            objectReader.Parse(pr);
        }