System.Runtime.Serialization.Formatters.Binary.BinaryTypeConverter.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 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)
        {
            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:
                    type = Converter.s_typeofString;
                    break;
                case BinaryTypeEnum.Object:
                    type = Converter.s_typeofObject;
                    isVariant = true;
                    break;
                case BinaryTypeEnum.ObjectArray:
                    type = Converter.s_typeofObjectArray;
                    break;
                case BinaryTypeEnum.StringArray:
                    type = Converter.s_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);
                        if (ReferenceEquals(type, Converter.s_typeofObject))
                        {
                            isVariant = true;
                        }
                    }
                    break;
                default:
                    throw new SerializationException(SR.Format(SR.Serialization_TypeRead, binaryTypeEnum.ToString()));
            }
        }
    }

Usage Example

示例#1
0
        internal ObjectMap(string objectName, string[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, object?[] typeInformationA, int[] memberAssemIds, ObjectReader objectReader, int objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
        {
            _objectName       = objectName;
            _memberNames      = memberNames;
            _binaryTypeEnumA  = binaryTypeEnumA;
            _typeInformationA = typeInformationA;
            _objectReader     = objectReader;
            _objectId         = objectId;
            _assemblyInfo     = assemblyInfo;

            if (assemblyInfo == null)
            {
                throw new SerializationException(SR.Format(SR.Serialization_Assembly, objectName));
            }

            _objectType  = objectReader.GetType(assemblyInfo, objectName);
            _memberTypes = new Type[memberNames.Length];

            for (int i = 0; i < memberNames.Length; i++)
            {
                BinaryTypeConverter.TypeFromInfo(
                    binaryTypeEnumA[i], typeInformationA[i], objectReader, (BinaryAssemblyInfo?)assemIdToAssemblyTable[memberAssemIds[i]],
                    out _, out _, out Type? type, out _);
                _memberTypes[i] = type;
            }

            _objectInfo = objectReader.CreateReadObjectInfo(_objectType, memberNames, null);
            if (!_objectInfo._isSi)
            {
                _objectInfo.GetMemberTypes(memberNames, _objectInfo._objectType);  // Check version match
            }
        }
All Usage Examples Of System.Runtime.Serialization.Formatters.Binary.BinaryTypeConverter::TypeFromInfo