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) { SerTrace.Log(this, "ReadObjectWithMapTyped"); if (bowmt == null) { bowmt = new BinaryObjectWithMapTyped(binaryHeaderEnum); } else { bowmt.binaryHeaderEnum = binaryHeaderEnum; } bowmt.Read(this); bowmt.Dump(); ReadObjectWithMapTyped(bowmt); }
//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)); } } }