private void ReadObject() { if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Read(this); ObjectMap objectMap = (ObjectMap)ObjectMapIdTable[_binaryObject._mapId]; if (objectMap == null) { throw new SerializationException(SR.Format(SR.Serialization_Map, _binaryObject._mapId)); } ObjectProgress op = GetOp(); ParseRecord pr = op._pr; _stack.Push(op); op._objectTypeEnum = InternalObjectTypeE.Object; op._binaryTypeEnumA = objectMap._binaryTypeEnumA; op._memberNames = objectMap._memberNames; op._memberTypes = objectMap._memberTypes; op._typeInformationA = objectMap._typeInformationA; op._memberLength = op._binaryTypeEnumA.Length; ObjectProgress objectOp = (ObjectProgress)_stack.PeekPeek(); if ((objectOp == null) || (objectOp._isInitial)) { // Non-Nested Object op._name = objectMap._objectName; pr._parseTypeEnum = InternalParseTypeE.Object; op._memberValueEnum = InternalMemberValueE.Empty; } else { // Nested Object pr._parseTypeEnum = InternalParseTypeE.Member; pr._memberValueEnum = InternalMemberValueE.Nested; op._memberValueEnum = InternalMemberValueE.Nested; switch (objectOp._objectTypeEnum) { case InternalObjectTypeE.Object: pr._name = objectOp._name; pr._memberTypeEnum = InternalMemberTypeE.Field; op._memberTypeEnum = InternalMemberTypeE.Field; break; case InternalObjectTypeE.Array: pr._memberTypeEnum = InternalMemberTypeE.Item; op._memberTypeEnum = InternalMemberTypeE.Item; break; default: throw new SerializationException(SR.Format(SR.Serialization_Map, objectOp._objectTypeEnum.ToString())); } } pr._objectId = _objectReader.GetId(_binaryObject._objectId); pr._objectInfo = objectMap.CreateObjectInfo(ref pr._si, ref pr._memberData); if (pr._objectId == _topId) { pr._objectPositionEnum = InternalObjectPositionE.Top; } pr._objectTypeEnum = InternalObjectTypeE.Object; pr._keyDt = objectMap._objectName; pr._dtType = objectMap._objectType; pr._dtTypeCode = InternalPrimitiveTypeE.Invalid; _objectReader.Parse(pr); }
//internal BinaryCrossAppDomainMap crossAppDomainMap; internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, String[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; nameInfo.Dump("WriteObject nameInfo"); typeNameInfo.Dump("WriteObject typeNameInfo"); int objectId = (int)nameInfo.NIobjectId; //if (objectId < 0) // objectId = --m_nestedObjectCount; if (objectId > 0) { BCLDebug.Trace("BINARY", "-----Top Level Object-----"); } String objectName = null; if (objectId < 0) { // Nested Object objectName = typeNameInfo.NIname; } else { // Non-Nested objectName = nameInfo.NIname; } SerTrace.Log(this, "WriteObject objectName ", objectName); if (objectMapTable == null) { objectMapTable = new Hashtable(); } ObjectMapInfo objectMapInfo = (ObjectMapInfo)objectMapTable[objectName]; if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes)) { // Object if (binaryObject == null) { binaryObject = new BinaryObject(); } binaryObject.Set(objectId, objectMapInfo.objectId); binaryObject.Dump(); binaryObject.Write(this); } else if (!typeNameInfo.NItransmitTypeOnObject) { // ObjectWithMap if (binaryObjectWithMap == null) { binaryObjectWithMap = new BinaryObjectWithMap(); } // BCL types are not placed into table assemId = (int)typeNameInfo.NIassemId; binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); binaryObjectWithMap.Dump(); binaryObjectWithMap.Write(this); if (objectMapInfo == null) { objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } else { // ObjectWithMapTyped BinaryTypeEnum[] binaryTypeEnumA = new BinaryTypeEnum[numMembers]; Object[] typeInformationA = new Object[numMembers]; int[] assemIdA = new int[numMembers]; for (int i = 0; i < numMembers; i++) { Object typeInformation = null; binaryTypeEnumA[i] = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; SerTrace.Log(this, "WriteObject ObjectWithMapTyped memberNames " , memberNames[i], ", memberType ", memberTypes[i], " binaryTypeEnum ", ((Enum)binaryTypeEnumA[i]).ToString() , ", typeInformation ", typeInformationA[i], " assemId ", assemIdA[i]); } if (binaryObjectWithMapTyped == null) { binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } // BCL types are not placed in table assemId = (int)typeNameInfo.NIassemId; binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); binaryObjectWithMapTyped.Dump(); binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) { objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } }
internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; int objectId = (int)nameInfo._objectId; string objectName = objectId < 0 ? objectName = typeNameInfo.NIname : // Nested Object objectName = nameInfo.NIname; // Non-Nested if (_objectMapTable == null) { _objectMapTable = new Dictionary <string, ObjectMapInfo>(); } ObjectMapInfo objectMapInfo; if (_objectMapTable.TryGetValue(objectName, out objectMapInfo) && objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes)) { // Object if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Set(objectId, objectMapInfo._objectId); _binaryObject.Write(this); } else if (!typeNameInfo._transmitTypeOnObject) { // ObjectWithMap if (_binaryObjectWithMap == null) { _binaryObjectWithMap = new BinaryObjectWithMap(); } // BCL types are not placed into table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); _binaryObjectWithMap.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } else { // ObjectWithMapTyped var binaryTypeEnumA = new BinaryTypeEnum[numMembers]; var typeInformationA = new object[numMembers]; var assemIdA = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object typeInformation = null; binaryTypeEnumA[i] = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; } if (_binaryObjectWithMapTyped == null) { _binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } // BCL types are not placed in table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); _binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } }
[System.Security.SecurityCritical] // auto-generated private void ReadObject() { SerTrace.Log( this, "ReadObject"); if (binaryObject == null) binaryObject = new BinaryObject(); binaryObject.Read(this); binaryObject.Dump(); ObjectMap objectMap = (ObjectMap)ObjectMapIdTable[binaryObject.mapId]; if (objectMap == null) throw new SerializationException(Environment.GetResourceString("Serialization_Map",binaryObject.mapId)); ObjectProgress op = GetOp(); ParseRecord pr = op.pr; stack.Push(op); op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; op.typeInformationA = objectMap.typeInformationA; op.memberLength = op.binaryTypeEnumA.Length; ObjectProgress objectOp = (ObjectProgress)stack.PeekPeek(); if ((objectOp == null) || (objectOp.isInitial)) { // Non-Nested Object SerTrace.Log( this, "ReadObject non-nested "); op.name = objectMap.objectName; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { // Nested Object SerTrace.Log( this, "ReadObject nested "); pr.PRparseTypeEnum = InternalParseTypeE.Member; pr.PRmemberValueEnum = InternalMemberValueE.Nested; op.memberValueEnum = InternalMemberValueE.Nested; switch (objectOp.objectTypeEnum) { case InternalObjectTypeE.Object: pr.PRname = objectOp.name; pr.PRmemberTypeEnum = InternalMemberTypeE.Field; op.memberTypeEnum = InternalMemberTypeE.Field; break; case InternalObjectTypeE.Array: pr.PRmemberTypeEnum = InternalMemberTypeE.Item; op.memberTypeEnum = InternalMemberTypeE.Item; break; default: throw new SerializationException(Environment.GetResourceString("Serialization_Map",((Enum)objectOp.objectTypeEnum).ToString())); } } pr.PRobjectId = objectReader.GetId((long)binaryObject.objectId); SerTrace.Log( this, "ReadObject binaryObject.objectId ",pr.PRobjectId); pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); if (pr.PRobjectId == topId) pr.PRobjectPositionEnum = InternalObjectPositionE.Top; pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRkeyDt = objectMap.objectName; pr.PRdtType = objectMap.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; objectReader.Parse(pr); }
internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { this.InternalWriteItemNull(); int nIobjectId = (int) nameInfo.NIobjectId; string name = null; if (nIobjectId < 0) { name = typeNameInfo.NIname; } else { name = nameInfo.NIname; } if (this.objectMapTable == null) { this.objectMapTable = new Hashtable(); } ObjectMapInfo info = (ObjectMapInfo) this.objectMapTable[name]; if ((info != null) && info.isCompatible(numMembers, memberNames, memberTypes)) { if (this.binaryObject == null) { this.binaryObject = new BinaryObject(); } this.binaryObject.Set(nIobjectId, info.objectId); this.binaryObject.Write(this); } else { int nIassemId; if (!typeNameInfo.NItransmitTypeOnObject) { if (this.binaryObjectWithMap == null) { this.binaryObjectWithMap = new BinaryObjectWithMap(); } nIassemId = (int) typeNameInfo.NIassemId; this.binaryObjectWithMap.Set(nIobjectId, name, numMembers, memberNames, nIassemId); this.binaryObjectWithMap.Dump(); this.binaryObjectWithMap.Write(this); if (info == null) { this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes)); } } else { BinaryTypeEnum[] binaryTypeEnumA = new BinaryTypeEnum[numMembers]; object[] typeInformationA = new object[numMembers]; int[] memberAssemIds = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object typeInformation = null; binaryTypeEnumA[i] = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, this.objectWriter, out typeInformation, out nIassemId); typeInformationA[i] = typeInformation; memberAssemIds[i] = nIassemId; } if (this.binaryObjectWithMapTyped == null) { this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } nIassemId = (int) typeNameInfo.NIassemId; this.binaryObjectWithMapTyped.Set(nIobjectId, name, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, nIassemId); this.binaryObjectWithMapTyped.Write(this); if (info == null) { this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes)); } } } }
//internal BinaryCrossAppDomainMap crossAppDomainMap; internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, String[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; #if _DEBUG nameInfo.Dump("WriteObject nameInfo"); typeNameInfo.Dump("WriteObject typeNameInfo"); #endif int objectId = (int)nameInfo.NIobjectId; //if (objectId < 0) // objectId = --m_nestedObjectCount; if (objectId > 0) { BCLDebug.Trace("BINARY", "-----Top Level Object-----"); } String objectName = null; if (objectId < 0) { // Nested Object objectName = typeNameInfo.NIname; } else { // Non-Nested objectName = nameInfo.NIname; } SerTrace.Log( this, "WriteObject objectName ",objectName); if (objectMapTable == null) { objectMapTable = new Hashtable(); } ObjectMapInfo objectMapInfo = (ObjectMapInfo)objectMapTable[objectName]; if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes)) { // Object if (binaryObject == null) binaryObject = new BinaryObject(); binaryObject.Set(objectId, objectMapInfo.objectId); #if _DEBUG binaryObject.Dump(); #endif binaryObject.Write(this); } else if (!typeNameInfo.NItransmitTypeOnObject) { // ObjectWithMap if (binaryObjectWithMap == null) binaryObjectWithMap = new BinaryObjectWithMap(); // BCL types are not placed into table assemId = (int)typeNameInfo.NIassemId; binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); binaryObjectWithMap.Dump(); binaryObjectWithMap.Write(this); if (objectMapInfo == null) objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } else { // ObjectWithMapTyped BinaryTypeEnum[] binaryTypeEnumA = new BinaryTypeEnum[numMembers]; Object[] typeInformationA = new Object[numMembers]; int[] assemIdA = new int[numMembers]; for (int i=0; i<numMembers; i++) { Object typeInformation = null; binaryTypeEnumA[i] = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; SerTrace.Log( this, "WriteObject ObjectWithMapTyped memberNames " ,memberNames[i],", memberType ",memberTypes[i]," binaryTypeEnum ",((Enum)binaryTypeEnumA[i]).ToString() ,", typeInformation ",typeInformationA[i]," assemId ",assemIdA[i]); } if (binaryObjectWithMapTyped == null) binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); // BCL types are not placed in table assemId = (int)typeNameInfo.NIassemId; binaryObjectWithMapTyped.Set(objectId, objectName, numMembers,memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); #if _DEBUG binaryObjectWithMapTyped.Dump(); #endif binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } }
private void ReadObject() { if (this.binaryObject == null) { this.binaryObject = new BinaryObject(); } this.binaryObject.Read(this); this.binaryObject.Dump(); ObjectMap map = (ObjectMap) this.ObjectMapIdTable[this.binaryObject.mapId]; if (map == null) { throw new SerializationException(Environment.GetResourceString("Serialization_Map", new object[] { this.binaryObject.mapId })); } ObjectProgress op = this.GetOp(); ParseRecord pr = op.pr; this.stack.Push(op); op.objectTypeEnum = InternalObjectTypeE.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) this.stack.PeekPeek(); if ((progress2 == null) || progress2.isInitial) { op.name = map.objectName; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { pr.PRparseTypeEnum = InternalParseTypeE.Member; pr.PRmemberValueEnum = InternalMemberValueE.Nested; op.memberValueEnum = InternalMemberValueE.Nested; switch (progress2.objectTypeEnum) { case InternalObjectTypeE.Object: pr.PRname = progress2.name; pr.PRmemberTypeEnum = InternalMemberTypeE.Field; op.memberTypeEnum = InternalMemberTypeE.Field; goto Label_019B; case InternalObjectTypeE.Array: pr.PRmemberTypeEnum = InternalMemberTypeE.Item; op.memberTypeEnum = InternalMemberTypeE.Item; goto Label_019B; } throw new SerializationException(Environment.GetResourceString("Serialization_Map", new object[] { progress2.objectTypeEnum.ToString() })); } Label_019B: pr.PRobjectId = this.objectReader.GetId((long) this.binaryObject.objectId); pr.PRobjectInfo = map.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); if (pr.PRobjectId == this.topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRkeyDt = map.objectName; pr.PRdtType = map.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; this.objectReader.Parse(pr); }
private void ReadObject() { if (this.binaryObject == null) { this.binaryObject = new BinaryObject(); } this.binaryObject.Read(this); this.binaryObject.Dump(); ObjectMap objectMap = (ObjectMap)this.ObjectMapIdTable[this.binaryObject.mapId]; if (objectMap == null) { throw new SerializationException(Environment.GetResourceString("Serialization_Map", (object)this.binaryObject.mapId)); } ObjectProgress op = this.GetOp(); ParseRecord pr = op.pr; this.stack.Push((object)op); op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; op.typeInformationA = objectMap.typeInformationA; ObjectProgress objectProgress1 = op; int length = objectProgress1.binaryTypeEnumA.Length; objectProgress1.memberLength = length; ObjectProgress objectProgress2 = (ObjectProgress)this.stack.PeekPeek(); if (objectProgress2 == null || objectProgress2.isInitial) { op.name = objectMap.objectName; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { pr.PRparseTypeEnum = InternalParseTypeE.Member; pr.PRmemberValueEnum = InternalMemberValueE.Nested; op.memberValueEnum = InternalMemberValueE.Nested; switch (objectProgress2.objectTypeEnum) { case InternalObjectTypeE.Object: pr.PRname = objectProgress2.name; pr.PRmemberTypeEnum = InternalMemberTypeE.Field; op.memberTypeEnum = InternalMemberTypeE.Field; break; case InternalObjectTypeE.Array: pr.PRmemberTypeEnum = InternalMemberTypeE.Item; op.memberTypeEnum = InternalMemberTypeE.Item; break; default: throw new SerializationException(Environment.GetResourceString("Serialization_Map", (object)objectProgress2.objectTypeEnum.ToString())); } } pr.PRobjectId = this.objectReader.GetId((long)this.binaryObject.objectId); pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); if (pr.PRobjectId == this.topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRkeyDt = objectMap.objectName; pr.PRdtType = objectMap.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; this.objectReader.Parse(pr); }
internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { this.InternalWriteItemNull(); int objectId = (int)nameInfo.NIobjectId; string name = objectId >= 0 ? nameInfo.NIname : typeNameInfo.NIname; if (this.objectMapTable == null) { this.objectMapTable = new Hashtable(); } ObjectMapInfo objectMapInfo = (ObjectMapInfo)this.objectMapTable[(object)name]; if (objectMapInfo != null && objectMapInfo.isCompatible(numMembers, memberNames, memberTypes)) { if (this.binaryObject == null) { this.binaryObject = new BinaryObject(); } this.binaryObject.Set(objectId, objectMapInfo.objectId); this.binaryObject.Write(this); } else if (!typeNameInfo.NItransmitTypeOnObject) { if (this.binaryObjectWithMap == null) { this.binaryObjectWithMap = new BinaryObjectWithMap(); } int assemId = (int)typeNameInfo.NIassemId; this.binaryObjectWithMap.Set(objectId, name, numMembers, memberNames, assemId); this.binaryObjectWithMap.Dump(); this.binaryObjectWithMap.Write(this); if (objectMapInfo != null) { return; } this.objectMapTable.Add((object)name, (object)new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } else { BinaryTypeEnum[] binaryTypeEnumA = new BinaryTypeEnum[numMembers]; object[] typeInformationA = new object[numMembers]; int[] memberAssemIds = new int[numMembers]; int assemId; for (int index = 0; index < numMembers; ++index) { object typeInformation = (object)null; binaryTypeEnumA[index] = BinaryConverter.GetBinaryTypeInfo(memberTypes[index], memberObjectInfos[index], (string)null, this.objectWriter, out typeInformation, out assemId); typeInformationA[index] = typeInformation; memberAssemIds[index] = assemId; } if (this.binaryObjectWithMapTyped == null) { this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } assemId = (int)typeNameInfo.NIassemId; this.binaryObjectWithMapTyped.Set(objectId, name, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, assemId); this.binaryObjectWithMapTyped.Write(this); if (objectMapInfo != null) { return; } this.objectMapTable.Add((object)name, (object)new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } }
internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { InternalWriteItemNull(); int assemId; int objectId = (int)nameInfo._objectId; string objectName = objectId < 0 ? objectName = typeNameInfo.NIname : // Nested Object objectName = nameInfo.NIname; // Non-Nested if (_objectMapTable == null) { _objectMapTable = new Dictionary<string, ObjectMapInfo>(); } ObjectMapInfo objectMapInfo; if (_objectMapTable.TryGetValue(objectName, out objectMapInfo) && objectMapInfo.IsCompatible(numMembers, memberNames, memberTypes)) { // Object if (_binaryObject == null) { _binaryObject = new BinaryObject(); } _binaryObject.Set(objectId, objectMapInfo._objectId); _binaryObject.Write(this); } else if (!typeNameInfo._transmitTypeOnObject) { // ObjectWithMap if (_binaryObjectWithMap == null) { _binaryObjectWithMap = new BinaryObjectWithMap(); } // BCL types are not placed into table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMap.Set(objectId, objectName, numMembers, memberNames, assemId); _binaryObjectWithMap.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } else { // ObjectWithMapTyped var binaryTypeEnumA = new BinaryTypeEnum[numMembers]; var typeInformationA = new object[numMembers]; var assemIdA = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object typeInformation = null; binaryTypeEnumA[i] = BinaryTypeConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, _objectWriter, out typeInformation, out assemId); typeInformationA[i] = typeInformation; assemIdA[i] = assemId; } if (_binaryObjectWithMapTyped == null) { _binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } // BCL types are not placed in table assemId = (int)typeNameInfo._assemId; _binaryObjectWithMapTyped.Set(objectId, objectName, numMembers, memberNames, binaryTypeEnumA, typeInformationA, assemIdA, assemId); _binaryObjectWithMapTyped.Write(this); if (objectMapInfo == null) { _objectMapTable.Add(objectName, new ObjectMapInfo(objectId, numMembers, memberNames, memberTypes)); } } }
private void ReadObject() { SerTrace.Log(this, "ReadObject"); if (binaryObject == null) { binaryObject = new BinaryObject(); } binaryObject.Read(this); binaryObject.Dump(); ObjectMap objectMap = (ObjectMap)ObjectMapIdTable[binaryObject.mapId]; if (objectMap == null) { throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_Map"), binaryObject.mapId)); } ObjectProgress op = GetOp(); ParseRecord pr = op.pr; stack.Push(op); op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; op.typeInformationA = objectMap.typeInformationA; op.memberLength = op.binaryTypeEnumA.Length; ObjectProgress objectOp = (ObjectProgress)stack.PeekPeek(); if ((objectOp == null) || (objectOp.isInitial)) { // Non-Nested Object SerTrace.Log(this, "ReadObject non-nested "); op.name = objectMap.objectName; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { // Nested Object SerTrace.Log(this, "ReadObject nested "); pr.PRparseTypeEnum = InternalParseTypeE.Member; pr.PRmemberValueEnum = InternalMemberValueE.Nested; op.memberValueEnum = InternalMemberValueE.Nested; switch (objectOp.objectTypeEnum) { case InternalObjectTypeE.Object: pr.PRname = objectOp.name; pr.PRmemberTypeEnum = InternalMemberTypeE.Field; op.memberTypeEnum = InternalMemberTypeE.Field; break; case InternalObjectTypeE.Array: pr.PRmemberTypeEnum = InternalMemberTypeE.Item; op.memberTypeEnum = InternalMemberTypeE.Item; break; default: throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_Map"), ((Enum)objectOp.objectTypeEnum).ToString())); } } pr.PRobjectId = objectReader.GetId((long)binaryObject.objectId); SerTrace.Log(this, "ReadObject binaryObject.objectId ", pr.PRobjectId); pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); if (pr.PRobjectId == topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRkeyDt = objectMap.objectName; pr.PRdtType = objectMap.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; objectReader.Parse(pr); }
internal void WriteObject(NameInfo nameInfo, NameInfo typeNameInfo, int numMembers, string[] memberNames, Type[] memberTypes, WriteObjectInfo[] memberObjectInfos) { this.InternalWriteItemNull(); int nIobjectId = (int)nameInfo.NIobjectId; string name = null; if (nIobjectId < 0) { name = typeNameInfo.NIname; } else { name = nameInfo.NIname; } if (this.objectMapTable == null) { this.objectMapTable = new Hashtable(); } ObjectMapInfo info = (ObjectMapInfo)this.objectMapTable[name]; if ((info != null) && info.isCompatible(numMembers, memberNames, memberTypes)) { if (this.binaryObject == null) { this.binaryObject = new BinaryObject(); } this.binaryObject.Set(nIobjectId, info.objectId); this.binaryObject.Write(this); } else { int nIassemId; if (!typeNameInfo.NItransmitTypeOnObject) { if (this.binaryObjectWithMap == null) { this.binaryObjectWithMap = new BinaryObjectWithMap(); } nIassemId = (int)typeNameInfo.NIassemId; this.binaryObjectWithMap.Set(nIobjectId, name, numMembers, memberNames, nIassemId); this.binaryObjectWithMap.Dump(); this.binaryObjectWithMap.Write(this); if (info == null) { this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes)); } } else { BinaryTypeEnum[] binaryTypeEnumA = new BinaryTypeEnum[numMembers]; object[] typeInformationA = new object[numMembers]; int[] memberAssemIds = new int[numMembers]; for (int i = 0; i < numMembers; i++) { object typeInformation = null; binaryTypeEnumA[i] = BinaryConverter.GetBinaryTypeInfo(memberTypes[i], memberObjectInfos[i], null, this.objectWriter, out typeInformation, out nIassemId); typeInformationA[i] = typeInformation; memberAssemIds[i] = nIassemId; } if (this.binaryObjectWithMapTyped == null) { this.binaryObjectWithMapTyped = new BinaryObjectWithMapTyped(); } nIassemId = (int)typeNameInfo.NIassemId; this.binaryObjectWithMapTyped.Set(nIobjectId, name, numMembers, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, nIassemId); this.binaryObjectWithMapTyped.Write(this); if (info == null) { this.objectMapTable.Add(name, new ObjectMapInfo(nIobjectId, numMembers, memberNames, memberTypes)); } } } }