internal void ReadCrossAppDomainMap() { BinaryCrossAppDomainMap record = new BinaryCrossAppDomainMap(); record.Read(this); object mapObject = _objectReader.CrossAppDomainArray(record._crossAppDomainArrayIndex); BinaryObjectWithMap binaryObjectWithMap = mapObject as BinaryObjectWithMap; if (binaryObjectWithMap != null) { ReadObjectWithMap(binaryObjectWithMap); } else { BinaryObjectWithMapTyped binaryObjectWithMapTyped = mapObject as BinaryObjectWithMapTyped; if (binaryObjectWithMapTyped != null) { ReadObjectWithMapTyped(binaryObjectWithMapTyped); } else { throw new SerializationException(SR.Format(SR.Serialization_CrossAppDomainError, "BinaryObjectMap", mapObject)); } } }
internal void ReadCrossAppDomainMap() { BinaryCrossAppDomainMap crossAppDomainMap = new BinaryCrossAppDomainMap(); crossAppDomainMap.Read(this); crossAppDomainMap.Dump(); object obj = this.objectReader.CrossAppDomainArray(crossAppDomainMap.crossAppDomainArrayIndex); BinaryObjectWithMap record1 = obj as BinaryObjectWithMap; if (record1 != null) { record1.Dump(); this.ReadObjectWithMap(record1); } else { BinaryObjectWithMapTyped record2 = obj as BinaryObjectWithMapTyped; if (record2 != null) { this.ReadObjectWithMapTyped(record2); } else { throw new SerializationException(Environment.GetResourceString("Serialization_CrossAppDomainError", (object)"BinaryObjectMap", obj)); } } }
internal void ReadCrossAppDomainMap() { SerTrace.Log(this, "ReadObjectWithCrossAppDomainMap"); BinaryCrossAppDomainMap record = new BinaryCrossAppDomainMap(); record.Read(this); record.Dump(); Object mapObject = objectReader.CrossAppDomainArray(record.crossAppDomainArrayIndex); BinaryObjectWithMap binaryObjectWithMap = mapObject as BinaryObjectWithMap; if (binaryObjectWithMap != null) { binaryObjectWithMap.Dump(); ReadObjectWithMap(binaryObjectWithMap); } else { BinaryObjectWithMapTyped binaryObjectWithMapTyped = mapObject as BinaryObjectWithMapTyped; if (binaryObjectWithMapTyped != null) { binaryObjectWithMapTyped.Dump(); ReadObjectWithMapTyped(binaryObjectWithMapTyped); } else { throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_CrossAppDomainError"), "BinaryObjectMap", mapObject)); } } }
internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) { if (_bowmt == null) { _bowmt = new BinaryObjectWithMapTyped(binaryHeaderEnum); } else { _bowmt._binaryHeaderEnum = binaryHeaderEnum; } _bowmt.Read(this); ReadObjectWithMapTyped(_bowmt); }
internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) { if (this.bowmt == null) { this.bowmt = new BinaryObjectWithMapTyped(binaryHeaderEnum); } else { this.bowmt.binaryHeaderEnum = binaryHeaderEnum; } this.bowmt.Read(this); this.ReadObjectWithMapTyped(this.bowmt); }
internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) { SerTrace.Log(this, "ReadObjectWithMapTyped"); if (bowmt == null) { bowmt = new BinaryObjectWithMapTyped(binaryHeaderEnum); } else { bowmt.binaryHeaderEnum = binaryHeaderEnum; } bowmt.Read(this); bowmt.Dump(); ReadObjectWithMapTyped(bowmt); }
internal void ReadCrossAppDomainMap() { BinaryCrossAppDomainMap map = new BinaryCrossAppDomainMap(); map.Read(this); map.Dump(); object obj2 = this.objectReader.CrossAppDomainArray(map.crossAppDomainArrayIndex); BinaryObjectWithMap record = obj2 as BinaryObjectWithMap; if (record != null) { record.Dump(); this.ReadObjectWithMap(record); } else { BinaryObjectWithMapTyped typed = obj2 as BinaryObjectWithMapTyped; if (typed == null) { throw new SerializationException(Environment.GetResourceString("Serialization_CrossAppDomainError", new object[] { "BinaryObjectMap", obj2 })); } this.ReadObjectWithMapTyped(typed); } }
private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) { BinaryAssemblyInfo assemblyInfo = null; ObjectProgress op = GetOp(); ParseRecord pr = op._pr; _stack.Push(op); if (record._binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId) { if (record._assemId < 1) { throw new SerializationException(SR.Format(SR.Serialization_AssemblyId, record._name)); } assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[record._assemId]; if (assemblyInfo == null) { throw new SerializationException(SR.Format(SR.Serialization_AssemblyId, record._assemId + " " + record._name)); } } else if (record._binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped) { assemblyInfo = SystemAssemblyInfo; // Urt assembly } ObjectMap objectMap = ObjectMap.Create(record._name, record._memberNames, record._binaryTypeEnumA, record._typeInformationA, record._memberAssemIds, _objectReader, record._objectId, assemblyInfo, AssemIdToAssemblyTable); ObjectMapIdTable[record._objectId] = objectMap; op._objectTypeEnum = InternalObjectTypeE.Object; op._binaryTypeEnumA = objectMap._binaryTypeEnumA; op._typeInformationA = objectMap._typeInformationA; op._memberLength = op._binaryTypeEnumA.Length; op._memberNames = objectMap._memberNames; op._memberTypes = objectMap._memberTypes; ObjectProgress objectOp = (ObjectProgress)_stack.PeekPeek(); if ((objectOp == null) || (objectOp._isInitial)) { // Non-Nested Object op._name = record._name; 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_ObjectTypeEnum, objectOp._objectTypeEnum.ToString())); } } pr._objectTypeEnum = InternalObjectTypeE.Object; pr._objectInfo = objectMap.CreateObjectInfo(ref pr._si, ref pr._memberData); pr._objectId = _objectReader.GetId(record._objectId); if (pr._objectId == _topId) { pr._objectPositionEnum = InternalObjectPositionE.Top; } pr._keyDt = record._name; pr._dtType = objectMap._objectType; pr._dtTypeCode = InternalPrimitiveTypeE.Invalid; _objectReader.Parse(pr); }
[System.Security.SecurityCritical] // auto-generated private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) { BinaryAssemblyInfo assemblyInfo = null; ObjectProgress op = GetOp(); ParseRecord pr = op.pr; stack.Push(op); if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId) { if (record.assemId < 1) throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId",record.name)); assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[record.assemId]; if (assemblyInfo == null) throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId",record.assemId+" "+record.name)); SerTrace.Log( this, "ReadObjectWithMapTyped lookup assemIdToAssembly assemId ",record.assemId," assembly ",assemblyInfo.assemblyString); } else if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped) { assemblyInfo = SystemAssemblyInfo; // Urt assembly } ObjectMap objectMap = ObjectMap.Create(record.name, record.memberNames, record.binaryTypeEnumA, record.typeInformationA, record.memberAssemIds, objectReader, record.objectId, assemblyInfo, AssemIdToAssemblyTable); ObjectMapIdTable[record.objectId] = objectMap; op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.typeInformationA = objectMap.typeInformationA; op.memberLength = op.binaryTypeEnumA.Length; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; ObjectProgress objectOp = (ObjectProgress)stack.PeekPeek(); if ((objectOp == null) || (objectOp.isInitial)) { // Non-Nested Object op.name = record.name; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { // Nested Object 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_ObjectTypeEnum",((Enum)objectOp.objectTypeEnum).ToString())); } } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); pr.PRobjectId = objectReader.GetId((long)record.objectId); if (pr.PRobjectId == topId) pr.PRobjectPositionEnum = InternalObjectPositionE.Top; pr.PRkeyDt = record.name; 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) { 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)); } } }
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 ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) { BinaryAssemblyInfo assemblyInfo = null; ObjectProgress op = GetOp(); ParseRecord pr = op.pr; stack.Push(op); if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId) { if (record.assemId < 1) { throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_AssemblyId"), record.name)); } assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[record.assemId]; if (assemblyInfo == null) { throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_AssemblyId"), record.assemId + " " + record.name)); } SerTrace.Log(this, "ReadObjectWithMapTyped lookup assemIdToAssembly assemId ", record.assemId, " assembly ", assemblyInfo.assemblyString); } else if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped) { assemblyInfo = SystemAssemblyInfo; // Urt assembly } ObjectMap objectMap = ObjectMap.Create(record.name, record.memberNames, record.binaryTypeEnumA, record.typeInformationA, record.memberAssemIds, objectReader, record.objectId, assemblyInfo, AssemIdToAssemblyTable); ObjectMapIdTable[record.objectId] = objectMap; op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.typeInformationA = objectMap.typeInformationA; op.memberLength = op.binaryTypeEnumA.Length; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; ObjectProgress objectOp = (ObjectProgress)stack.PeekPeek(); if ((objectOp == null) || (objectOp.isInitial)) { // Non-Nested Object op.name = record.name; pr.PRparseTypeEnum = InternalParseTypeE.Object; op.memberValueEnum = InternalMemberValueE.Empty; } else { // Nested Object 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_ObjectTypeEnum"), ((Enum)objectOp.objectTypeEnum).ToString())); } } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); pr.PRobjectId = objectReader.GetId((long)record.objectId); if (pr.PRobjectId == topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRkeyDt = record.name; 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)); } } } }
private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) { BinaryAssemblyInfo assemblyInfo = (BinaryAssemblyInfo)null; ObjectProgress op = this.GetOp(); ParseRecord pr = op.pr; this.stack.Push((object)op); if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId) { if (record.assemId < 1) { throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", (object)record.name)); } assemblyInfo = (BinaryAssemblyInfo)this.AssemIdToAssemblyTable[record.assemId]; if (assemblyInfo == null) { throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", (object)(record.assemId.ToString() + " " + record.name))); } } else if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped) { assemblyInfo = this.SystemAssemblyInfo; } ObjectMap objectMap = ObjectMap.Create(record.name, record.memberNames, record.binaryTypeEnumA, record.typeInformationA, record.memberAssemIds, this.objectReader, record.objectId, assemblyInfo, this.AssemIdToAssemblyTable); this.ObjectMapIdTable[record.objectId] = (object)objectMap; op.objectTypeEnum = InternalObjectTypeE.Object; op.binaryTypeEnumA = objectMap.binaryTypeEnumA; op.typeInformationA = objectMap.typeInformationA; ObjectProgress objectProgress1 = op; int length = objectProgress1.binaryTypeEnumA.Length; objectProgress1.memberLength = length; op.memberNames = objectMap.memberNames; op.memberTypes = objectMap.memberTypes; ObjectProgress objectProgress2 = (ObjectProgress)this.stack.PeekPeek(); if (objectProgress2 == null || objectProgress2.isInitial) { op.name = record.name; 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_ObjectTypeEnum", (object)objectProgress2.objectTypeEnum.ToString())); } } pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRobjectInfo = objectMap.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); pr.PRobjectId = this.objectReader.GetId((long)record.objectId); if (pr.PRobjectId == this.topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRkeyDt = record.name; pr.PRdtType = objectMap.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; this.objectReader.Parse(pr); }
//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)); } }
[System.Security.SecurityCritical] // auto-generated internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) { SerTrace.Log( this, "ReadObjectWithMapTyped"); if (bowmt == null) bowmt = new BinaryObjectWithMapTyped(binaryHeaderEnum); else bowmt.binaryHeaderEnum = binaryHeaderEnum; bowmt.Read(this); #if _DEBUG bowmt.Dump(); #endif ReadObjectWithMapTyped(bowmt); }
private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) { BinaryAssemblyInfo assemblyInfo = null; ObjectProgress op = this.GetOp(); ParseRecord pr = op.pr; this.stack.Push(op); if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTypedAssemId) { if (record.assemId < 1) { throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { record.name })); } assemblyInfo = (BinaryAssemblyInfo) this.AssemIdToAssemblyTable[record.assemId]; if (assemblyInfo == null) { throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { record.assemId + " " + record.name })); } } else if (record.binaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped) { assemblyInfo = this.SystemAssemblyInfo; } ObjectMap map = ObjectMap.Create(record.name, record.memberNames, record.binaryTypeEnumA, record.typeInformationA, record.memberAssemIds, this.objectReader, record.objectId, assemblyInfo, this.AssemIdToAssemblyTable); this.ObjectMapIdTable[record.objectId] = map; op.objectTypeEnum = InternalObjectTypeE.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) this.stack.PeekPeek(); if ((progress2 == null) || progress2.isInitial) { op.name = record.name; 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_0211; case InternalObjectTypeE.Array: pr.PRmemberTypeEnum = InternalMemberTypeE.Item; op.memberTypeEnum = InternalMemberTypeE.Item; goto Label_0211; } throw new SerializationException(Environment.GetResourceString("Serialization_ObjectTypeEnum", new object[] { progress2.objectTypeEnum.ToString() })); } Label_0211: pr.PRobjectTypeEnum = InternalObjectTypeE.Object; pr.PRobjectInfo = map.CreateObjectInfo(ref pr.PRsi, ref pr.PRmemberData); pr.PRobjectId = this.objectReader.GetId((long) record.objectId); if (pr.PRobjectId == this.topId) { pr.PRobjectPositionEnum = InternalObjectPositionE.Top; } pr.PRkeyDt = record.name; pr.PRdtType = map.objectType; pr.PRdtTypeCode = InternalPrimitiveTypeE.Invalid; this.objectReader.Parse(pr); }
internal BinaryObjectWithMapTyped Copy() { BinaryObjectWithMapTyped newBOWM = new BinaryObjectWithMapTyped(binaryHeaderEnum); String[] newMemberNames = new String[numMembers]; Array.Copy(memberNames, newMemberNames, numMembers); BinaryTypeEnum[] newBinaryTypeEnumA = new BinaryTypeEnum[binaryTypeEnumA.Length]; Array.Copy(binaryTypeEnumA, newBinaryTypeEnumA, binaryTypeEnumA.Length); Object[] newTypeInformationA = new Object[typeInformationA.Length]; Array.Copy(typeInformationA, newTypeInformationA, typeInformationA.Length); Int32[] newMemberAssemIds = new Int32[memberAssemIds.Length]; Array.Copy(memberAssemIds, newMemberAssemIds, memberAssemIds.Length); newBOWM.Set(objectId, name, numMembers, newMemberNames, newBinaryTypeEnumA, newTypeInformationA, newMemberAssemIds, assemId); return newBOWM; }
//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) { 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)); } } } }