// Writes out an array element private void WriteArrayMember(WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, object data) { arrayElemTypeNameInfo._isArrayItem = true; if (CheckForNull(objectInfo, arrayElemTypeNameInfo, arrayElemTypeNameInfo, data)) { return; } NameInfo actualTypeInfo = null; Type dataType = null; bool isObjectOnMember = false; if (arrayElemTypeNameInfo._transmitTypeOnMember) { isObjectOnMember = true; } if (!isObjectOnMember && !arrayElemTypeNameInfo.IsSealed) { dataType = GetType(data); if (!ReferenceEquals(arrayElemTypeNameInfo._type, dataType)) { isObjectOnMember = true; } } if (isObjectOnMember) { // Object array, need type of member if (dataType == null) { dataType = GetType(data); } actualTypeInfo = TypeToNameInfo(dataType); actualTypeInfo._transmitTypeOnMember = true; actualTypeInfo._objectId = arrayElemTypeNameInfo._objectId; actualTypeInfo._assemId = arrayElemTypeNameInfo._assemId; actualTypeInfo._isArrayItem = true; } else { actualTypeInfo = arrayElemTypeNameInfo; actualTypeInfo._isArrayItem = true; } if (!WriteKnownValueClass(arrayElemTypeNameInfo, actualTypeInfo, data)) { object obj = data; bool assignUniqueIdForValueTypes = false; if (ReferenceEquals(arrayElemTypeNameInfo._type, Converter.s_typeofObject)) { assignUniqueIdForValueTypes = true; } long arrayId = Schedule(obj, assignUniqueIdForValueTypes, actualTypeInfo._type); arrayElemTypeNameInfo._objectId = arrayId; actualTypeInfo._objectId = arrayId; if (arrayId < 1) { WriteObjectInfo newObjectInfo = WriteObjectInfo.Serialize(obj, _surrogates, _context, _serObjectInfoInit, _formatterConverter, this, _binder); newObjectInfo._objectId = arrayId; newObjectInfo._assemId = !ReferenceEquals(arrayElemTypeNameInfo._type, Converter.s_typeofObject) && Nullable.GetUnderlyingType(arrayElemTypeNameInfo._type) == null ? actualTypeInfo._assemId : GetAssemblyId(newObjectInfo); NameInfo typeNameInfo = TypeToNameInfo(newObjectInfo); typeNameInfo._objectId = arrayId; newObjectInfo._objectId = arrayId; Write(newObjectInfo, actualTypeInfo, typeNameInfo); newObjectInfo.ObjectEnd(); } else { _serWriter.WriteItemObjectRef(arrayElemTypeNameInfo, (int)arrayId); } } if (arrayElemTypeNameInfo._transmitTypeOnMember) { PutNameInfo(actualTypeInfo); } }