System.Runtime.Serialization.Formatters.Binary.BinaryConverter.GetParserBinaryTypeInfo C# (CSharp) Method

GetParserBinaryTypeInfo() static private method

static private GetParserBinaryTypeInfo ( Type type, Object &typeInformation ) : BinaryTypeEnum
type System.Type
typeInformation Object
return BinaryTypeEnum
        internal static BinaryTypeEnum GetParserBinaryTypeInfo(Type type, out Object typeInformation)
        {
            SerTrace.Log("BinaryConverter", "GetParserBinaryTypeInfo Entry type ",type);        
            BinaryTypeEnum binaryTypeEnum;
            typeInformation = null;

            if (type == Converter.typeofString)
                binaryTypeEnum = BinaryTypeEnum.String;
            else if (type == Converter.typeofObject)
                binaryTypeEnum = BinaryTypeEnum.Object;
            else if (type == Converter.typeofObjectArray)
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            else if (type == Converter.typeofStringArray)
                binaryTypeEnum = BinaryTypeEnum.StringArray;
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
            else
            {
                InternalPrimitiveTypeE primitiveTypeEnum = Converter.ToCode(type);
                switch (primitiveTypeEnum)
                {
                    case InternalPrimitiveTypeE.Invalid:
                        if (Assembly.GetAssembly(type) == Converter.urtAssembly)
                            binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
                        else
                            binaryTypeEnum = BinaryTypeEnum.ObjectUser;

                        typeInformation = type.FullName;
                        break;
                    default:
                        binaryTypeEnum = BinaryTypeEnum.Primitive;
                        typeInformation = primitiveTypeEnum;
                        break;
                }
            }

            SerTrace.Log( "BinaryConverter", "GetParserBinaryTypeInfo Exit ",((Enum)binaryTypeEnum).ToString(),", typeInformation ",typeInformation);               
            return binaryTypeEnum;
        }

Usage Example

示例#1
0
 internal ObjectMap(string objectName, Type objectType, string[] memberNames, ObjectReader objectReader, int objectId, BinaryAssemblyInfo assemblyInfo)
 {
     this.isInitObjectInfo = true;
     this.objectName       = objectName;
     this.objectType       = objectType;
     this.memberNames      = memberNames;
     this.objectReader     = objectReader;
     this.objectId         = objectId;
     this.assemblyInfo     = assemblyInfo;
     this.objectInfo       = objectReader.CreateReadObjectInfo(objectType);
     this.memberTypes      = this.objectInfo.GetMemberTypes(memberNames, objectType);
     this.binaryTypeEnumA  = new BinaryTypeEnum[this.memberTypes.Length];
     this.typeInformationA = new object[this.memberTypes.Length];
     for (int i = 0; i < this.memberTypes.Length; i++)
     {
         object typeInformation = null;
         this.binaryTypeEnumA[i]  = BinaryConverter.GetParserBinaryTypeInfo(this.memberTypes[i], out typeInformation);
         this.typeInformationA[i] = typeInformation;
     }
 }