internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, String typeName, ObjectWriter objectWriter, out Object typeInformation, out int assemId)
{
SerTrace.Log("BinaryConverter", "GetBinaryTypeInfo Entry type ",type,", typeName ",typeName," objectInfo "+objectInfo);
BinaryTypeEnum binaryTypeEnum;
assemId = 0;
typeInformation = null;
if (type == Converter.typeofString)
binaryTypeEnum = BinaryTypeEnum.String;
else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi))
&& (type == Converter.typeofObject))
{
// If objectInfo.Si then can be a surrogate which will change the type
binaryTypeEnum = BinaryTypeEnum.Object;
}
else if (type == Converter.typeofStringArray)
binaryTypeEnum = BinaryTypeEnum.StringArray;
else if (type == Converter.typeofObjectArray)
binaryTypeEnum = BinaryTypeEnum.ObjectArray;
else if (Converter.IsPrimitiveArray(type, out typeInformation))
binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
else
{
InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type);
switch (primitiveTypeEnum)
{
case InternalPrimitiveTypeE.Invalid:
String assembly = null;
if (objectInfo == null)
{
assembly = type.Assembly.FullName;
typeInformation = type.FullName;
}
else
{
assembly = objectInfo.GetAssemblyString();
typeInformation = objectInfo.GetTypeFullName();
}
if (assembly.Equals(Converter.urtAssemblyString))
{
binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
assemId = 0;
}
else
{
binaryTypeEnum = BinaryTypeEnum.ObjectUser;
BCLDebug.Assert(objectInfo!=null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object");
assemId = (int)objectInfo.assemId;
if (assemId == 0)
throw new SerializationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_AssemblyId"),typeInformation));
}
break;
default:
binaryTypeEnum = BinaryTypeEnum.Primitive;
typeInformation = primitiveTypeEnum;
break;
}
}
SerTrace.Log( "BinaryConverter", "GetBinaryTypeInfo Exit ",((Enum)binaryTypeEnum).ToString(),", typeInformation ",typeInformation," assemId ",assemId);
return binaryTypeEnum;
}