Esempio n. 1
0
 public 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(RemotingResources.SerializationAssemblyNotFound.Format(objectName));
     }
     this._objectType  = objectReader.GetType(assemblyInfo, objectName);
     this._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 _);
         this._memberTypes[i] = type;
     }
     this._objectInfo = objectReader.CreateReadObjectInfo(this._objectType, memberNames, null);
     if (!this._objectInfo.IsSi)
     {
         this._objectInfo.GetMemberTypes(memberNames, this._objectInfo.ObjectType);
     }
 }
        public Type GetType(BinaryAssemblyInfo assemblyInfo, string name)
        {
            Type typeFromAssembly;

            if ((this.previousName != null) && ((this.previousName.Length == name.Length) && (this.previousName.Equals(name) && ((this.previousAssemblyString != null) && ((this.previousAssemblyString.Length == assemblyInfo.AssemblyString.Length) && this.previousAssemblyString.Equals(assemblyInfo.AssemblyString))))))
            {
                typeFromAssembly = this.previousType;
            }
            else
            {
                typeFromAssembly = this.Bind(assemblyInfo.AssemblyString, name);
                if (typeFromAssembly == null)
                {
                    Assembly assm = assemblyInfo.GetAssembly();
                    if (this.isSimpleAssembly)
                    {
                        GetSimplyNamedTypeFromAssembly(assm, name, ref typeFromAssembly);
                    }
                    else
                    {
                        typeFromAssembly = FormatterServices.GetTypeFromAssembly(assm, name);
                    }
                    //if (typeFromAssembly != null)
                    //{
                    //    CheckTypeForwardedTo(assm, typeFromAssembly.Assembly, typeFromAssembly);
                    //}
                }
                this.previousAssemblyString = assemblyInfo.AssemblyString;
                this.previousName           = name;
                this.previousType           = typeFromAssembly;
            }
            return(typeFromAssembly);
        }
Esempio n. 3
0
 public 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++)
     {
         this._binaryTypeEnumA[i]  = BinaryTypeConverter.GetParserBinaryTypeInfo(this._memberTypes[i], out object typeInformation);
         this._typeInformationA[i] = typeInformation;
     }
 }
Esempio n. 4
0
 public static ObjectMap Create(string name, string[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, object[] typeInformationA, int[] memberAssemIds, ObjectReader objectReader, int objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
 {
     return(new ObjectMap(name, memberNames, binaryTypeEnumA, typeInformationA, memberAssemIds, objectReader, objectId, assemblyInfo, assemIdToAssemblyTable));
 }
Esempio n. 5
0
 public static ObjectMap Create(string name, Type objectType, string[] memberNames, ObjectReader objectReader, int objectId, BinaryAssemblyInfo assemblyInfo)
 {
     return(new ObjectMap(name, objectType, memberNames, objectReader, objectId, assemblyInfo));
 }
Esempio n. 6
0
        private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
        {
            BinaryAssemblyInfo assemblyInfo = null;
            ObjectProgress     op           = GetOp();
            ParseRecord        pr           = op._pr;

            stack.Push(op);
            if (record.BinaryHeaderEnum != BinaryHeaderEnum.ObjectWithMapTypedAssemId)
            {
                if (record.BinaryHeaderEnum == BinaryHeaderEnum.ObjectWithMapTyped)
                {
                    assemblyInfo = SystemAssemblyInfo;
                }
            }
            else
            {
                if (record.AssemId < 1)
                {
                    throw new SerializationException(RemotingResources.SerializationAssemblyId.Format(record.Name));
                }
                assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[record.AssemId];
                if (assemblyInfo == null)
                {
                    throw new SerializationException(RemotingResources.SerializationAssemblyId.Format(((int)record.AssemId).ToString() + " " + record.Name));
                }
            }
            ObjectMap map = ObjectMap.Create(record.Name, record.MemberNames, record.BinaryTypeEnumArray, record.TypeInformationArray, record.MemberAssemIds, objectReader, record.ObjectId, assemblyInfo, AssemIdToAssemblyTable);

            ObjectMapIdTable[record.ObjectId] = map;
            op._objectTypeEnum   = ObjectTypeEnum.Object;
            op._binaryTypeEnumA  = map._binaryTypeEnumA;
            op._typeInformationA = map._typeInformationA;
            op._memberLength     = op._binaryTypeEnumA.Length;
            op._memberNames      = map._memberNames;
            op._memberTypes      = map._memberTypes;
            ObjectProgress progress2 = (ObjectProgress)stack.PeekPeek();

            if (progress2 == null || progress2._isInitial)
            {
                op._name            = record.Name;
                pr.parseTypeEnum    = ParseTypeEnum.Object;
                op._memberValueEnum = MemberValueEnum.Empty;
            }
            else
            {
                pr.parseTypeEnum    = ParseTypeEnum.Member;
                pr.memberValueEnum  = MemberValueEnum.Nested;
                op._memberValueEnum = MemberValueEnum.Nested;
                ObjectTypeEnum ee = progress2._objectTypeEnum;
                if (ee == ObjectTypeEnum.Object)
                {
                    pr.name            = progress2._name;
                    pr.memberTypeEnum  = MemberTypeEnum.Field;
                    op._memberTypeEnum = MemberTypeEnum.Field;
                }
                else
                {
                    if (ee != ObjectTypeEnum.Array)
                    {
                        throw new SerializationException(RemotingResources.SerializationObjectTypeEnum.Format(progress2._objectTypeEnum.ToString()));
                    }
                    pr.memberTypeEnum  = MemberTypeEnum.Item;
                    op._memberTypeEnum = MemberTypeEnum.Item;
                }
            }
            pr.objectTypeEnum = ObjectTypeEnum.Object;
            pr.objectInfo     = map.CreateObjectInfo(ref pr.si, ref pr.memberData);
            pr.objectId       = objectReader.GetId((long)record.ObjectId);
            if (pr.objectId == topId)
            {
                pr.objectPositionEnum = ObjectPositionEnum.Top;
            }
            pr.keyDt      = record.Name;
            pr.dtType     = map._objectType;
            pr.dtTypeCode = PrimitiveTypeEnum.Invalid;
            objectReader.Parse(pr);
        }
        public static void TypeFromInfo(BinaryTypeEnum binaryTypeEnum, object typeInformation, ObjectReader objectReader, BinaryAssemblyInfo assemblyInfo, out PrimitiveTypeEnum primitiveTypeEnum, out string typeString, out Type type, out bool isVariant)
        {
            isVariant         = false;
            primitiveTypeEnum = PrimitiveTypeEnum.Invalid;
            typeString        = null;
            type = null;
            switch (binaryTypeEnum)
            {
            case BinaryTypeEnum.Primitive:
                primitiveTypeEnum = (PrimitiveTypeEnum)typeInformation;
                typeString        = Converter.ToComType(primitiveTypeEnum);
                type = Converter.ToType(primitiveTypeEnum);
                return;

            case BinaryTypeEnum.String:
                type = Converter.s_typeofString;
                return;

            case BinaryTypeEnum.Object:
                type      = Converter.s_typeofObject;
                isVariant = true;
                return;

            case BinaryTypeEnum.ObjectUrt:
            case BinaryTypeEnum.ObjectUser:
                if (typeInformation != null)
                {
                    typeString = typeInformation.ToString();
                    type       = objectReader.GetType(assemblyInfo, typeString);
                    if (type == Converter.s_typeofObject)
                    {
                        isVariant = true;
                        return;
                    }
                }
                return;

            case BinaryTypeEnum.ObjectArray:
                type = Converter.s_typeofObjectArray;
                return;

            case BinaryTypeEnum.StringArray:
                type = Converter.s_typeofStringArray;
                return;

            case BinaryTypeEnum.PrimitiveArray:
                primitiveTypeEnum = (PrimitiveTypeEnum)typeInformation;
                type = Converter.ToArrayType(primitiveTypeEnum);
                return;
            }
            throw new SerializationException(RemotingResources.SerializationTypeRead.Format(binaryTypeEnum));
        }