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));
}
}