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++; } } } }
private void ReadObject() { if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Read(this); ObjectMap map = (ObjectMap)ObjectMapIdTable[_binaryObject.MapId]; if (map == null) { throw new SerializationException(RemotingResources.SerializationMap.Format((int)_binaryObject.MapId)); } ObjectProgress op = GetOp(); ParseRecord pr = op._pr; stack.Push(op); op._objectTypeEnum = ObjectTypeEnum.Object; op._binaryTypeEnumA = map._binaryTypeEnumA; op._memberNames = map._memberNames; op._memberTypes = map._memberTypes; op._typeInformationA = map._typeInformationA; op._memberLength = op._binaryTypeEnumA.Length; ObjectProgress progress2 = (ObjectProgress)stack.PeekPeek(); if (progress2 == null || progress2._isInitial) { op._name = map._objectName; 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.SerializationMap.Format(progress2._objectTypeEnum.ToString())); } pr.memberTypeEnum = MemberTypeEnum.Item; op._memberTypeEnum = MemberTypeEnum.Item; } } pr.objectId = objectReader.GetId((long)_binaryObject.ObjectId); pr.objectInfo = map.CreateObjectInfo(ref pr.si, ref pr.memberData); if (pr.objectId == topId) { pr.objectPositionEnum = ObjectPositionEnum.Top; } pr.objectTypeEnum = ObjectTypeEnum.Object; pr.keyDt = map._objectName; pr.dtType = map._objectType; pr.dtTypeCode = PrimitiveTypeEnum.Invalid; objectReader.Parse(pr); }