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

TypeFromInfo() static private method

static private TypeFromInfo ( BinaryTypeEnum binaryTypeEnum, Object typeInformation, ObjectReader objectReader, BinaryAssemblyInfo assemblyInfo, InternalPrimitiveTypeE &primitiveTypeEnum, String &typeString, Type &type, bool &isVariant ) : void
binaryTypeEnum BinaryTypeEnum
typeInformation Object
objectReader ObjectReader
assemblyInfo BinaryAssemblyInfo
primitiveTypeEnum InternalPrimitiveTypeE
typeString String
type System.Type
isVariant bool
return void
        internal static void TypeFromInfo(BinaryTypeEnum binaryTypeEnum,
                                          Object typeInformation,
                                          ObjectReader objectReader,
                                          BinaryAssemblyInfo assemblyInfo,
                                          out InternalPrimitiveTypeE primitiveTypeEnum,
                                          out String typeString,
                                          out Type type,
                                          out bool isVariant)
        {
            SerTrace.Log( "BinaryConverter", "TypeFromInfo Entry  ",((Enum)binaryTypeEnum).ToString());

            isVariant = false;
            primitiveTypeEnum = InternalPrimitiveTypeE.Invalid;
            typeString = null;
            type = null;

            switch (binaryTypeEnum)
            {
                case BinaryTypeEnum.Primitive:
                    primitiveTypeEnum = (InternalPrimitiveTypeE)typeInformation;                    
                    typeString = Converter.ToComType(primitiveTypeEnum);
                    type = Converter.ToType(primitiveTypeEnum);
                    break;
                case BinaryTypeEnum.String:
                    //typeString = "System.String";
                    type = Converter.typeofString;
                    break;
                case BinaryTypeEnum.Object:
                    //typeString = "System.Object";
                    type = Converter.typeofObject;
                    isVariant = true; 
                    break;
                case BinaryTypeEnum.ObjectArray:
                    //typeString = "System.Object[]";
                    type = Converter.typeofObjectArray;
                    break;
                case BinaryTypeEnum.StringArray:
                    //typeString = "System.String[]";
                    type = Converter.typeofStringArray;
                    break;
                case BinaryTypeEnum.PrimitiveArray:
                    primitiveTypeEnum = (InternalPrimitiveTypeE)typeInformation;                    
                    type = Converter.ToArrayType(primitiveTypeEnum);
                    break;
                case BinaryTypeEnum.ObjectUser:
                case BinaryTypeEnum.ObjectUrt:
                    if (typeInformation != null)
                    {
                        typeString = typeInformation.ToString();
                        type = objectReader.GetType(assemblyInfo, typeString);
                        // Temporary for backward compatibility
                        if (type == Converter.typeofObject)
                            isVariant = true;
                    }
                    break;
                default:
                    throw new SerializationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_TypeRead"),((Enum)binaryTypeEnum).ToString()));                                     
            }

#if _DEBUG
                SerTrace.Log( "BinaryConverter", "TypeFromInfo Exit  "
                          ,((Enum)primitiveTypeEnum).ToString(),",typeString ",Util.PString(typeString)
                          ,", type ",Util.PString(type),", isVariant ",isVariant);      
#endif

        }

Usage Example

示例#1
0
 internal ObjectMap(string objectName, string[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, object[] typeInformationA, int[] memberAssemIds, ObjectReader objectReader, int objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
 {
     this.isInitObjectInfo = true;
     this.objectName       = objectName;
     this.memberNames      = memberNames;
     this.binaryTypeEnumA  = binaryTypeEnumA;
     this.typeInformationA = typeInformationA;
     this.objectReader     = objectReader;
     this.objectId         = objectId;
     this.assemblyInfo     = assemblyInfo;
     if (assemblyInfo == null)
     {
         throw new SerializationException(Environment.GetResourceString("Serialization_Assembly", new object[] { objectName }));
     }
     this.objectType  = objectReader.GetType(assemblyInfo, objectName);
     this.memberTypes = new Type[memberNames.Length];
     for (int i = 0; i < memberNames.Length; i++)
     {
         InternalPrimitiveTypeE ee;
         string str;
         Type   type;
         bool   flag;
         BinaryConverter.TypeFromInfo(binaryTypeEnumA[i], typeInformationA[i], objectReader, (BinaryAssemblyInfo)assemIdToAssemblyTable[memberAssemIds[i]], out ee, out str, out type, out flag);
         this.memberTypes[i] = type;
     }
     this.objectInfo = objectReader.CreateReadObjectInfo(this.objectType, memberNames, null);
     if (!this.objectInfo.isSi)
     {
         this.objectInfo.GetMemberTypes(memberNames, this.objectInfo.objectType);
     }
 }
All Usage Examples Of System.Runtime.Serialization.Formatters.Binary.BinaryConverter::TypeFromInfo