private void ReadObjectNull(BinaryHeaderEnum binaryHeaderEnum) { if (_objectNull == null) { _objectNull = new ObjectNull(); } _objectNull.Set(_objectNull.NullCount, binaryHeaderEnum); _objectNull.Read(this); ObjectProgress progress = (ObjectProgress)stack.Peek(); PRs.Init(); PRs.parseTypeEnum = ParseTypeEnum.Member; PRs.memberValueEnum = MemberValueEnum.Null; if (progress._objectTypeEnum == ObjectTypeEnum.Object) { PRs.memberTypeEnum = MemberTypeEnum.Field; PRs.name = progress._name; PRs.dtType = progress._dtType; } else { PRs.memberTypeEnum = MemberTypeEnum.Item; PRs.consecutiveNullArrayEntryCount = _objectNull.NullCount; progress.ArrayCountIncrement(_objectNull.NullCount - 1); } objectReader.Parse(PRs); }
private void ReadMemberReference() { if (_memberReference == null) { _memberReference = new MemberReference(); } _memberReference.Read(this); ObjectProgress progress = (ObjectProgress)stack.Peek(); PRs.Init(); PRs.idRef = objectReader.GetId((long)_memberReference._idRef); PRs.parseTypeEnum = ParseTypeEnum.Member; PRs.memberValueEnum = MemberValueEnum.Reference; if (progress._objectTypeEnum != ObjectTypeEnum.Object) { PRs.memberTypeEnum = MemberTypeEnum.Item; } else { PRs.memberTypeEnum = MemberTypeEnum.Field; PRs.name = progress._name; PRs.dtType = progress._dtType; } objectReader.Parse(PRs); }
private void ReadMemberPrimitiveUnTyped() { ObjectProgress progress = (ObjectProgress)stack.Peek(); if (memberPrimitiveUnTyped == null) { memberPrimitiveUnTyped = new MemberPrimitiveUnTyped(); } memberPrimitiveUnTyped.Set((PrimitiveTypeEnum)expectedTypeInformation); memberPrimitiveUnTyped.Read(this); PRs.Init(); PRs.varValue = memberPrimitiveUnTyped._value; PRs.dtTypeCode = (PrimitiveTypeEnum)expectedTypeInformation; PRs.dtType = Converter.ToType(PRs.dtTypeCode); PRs.parseTypeEnum = ParseTypeEnum.Member; PRs.memberValueEnum = MemberValueEnum.InlineValue; if (progress._objectTypeEnum != ObjectTypeEnum.Object) { PRs.memberTypeEnum = MemberTypeEnum.Item; } else { PRs.memberTypeEnum = MemberTypeEnum.Field; PRs.name = progress._name; } objectReader.Parse(PRs); }
private void ReadMemberPrimitiveTyped() { if (_memberPrimitiveTyped == null) { _memberPrimitiveTyped = new MemberPrimitiveTyped(); } _memberPrimitiveTyped.Read(this); PRs.objectTypeEnum = ObjectTypeEnum.Object; ObjectProgress progress = (ObjectProgress)stack.Peek(); PRs.Init(); PRs.varValue = _memberPrimitiveTyped.Value; PRs.keyDt = Converter.ToComType(_memberPrimitiveTyped.PrimitiveTypeEnum); PRs.dtType = Converter.ToType(_memberPrimitiveTyped.PrimitiveTypeEnum); PRs.dtTypeCode = _memberPrimitiveTyped.PrimitiveTypeEnum; if (progress == null) { PRs.parseTypeEnum = ParseTypeEnum.Object; PRs.name = "System.Variant"; } else { PRs.parseTypeEnum = ParseTypeEnum.Member; PRs.memberValueEnum = MemberValueEnum.InlineValue; ObjectTypeEnum ee = progress._objectTypeEnum; if (ee == ObjectTypeEnum.Object) { PRs.name = progress._name; PRs.memberTypeEnum = MemberTypeEnum.Field; } else { if (ee != ObjectTypeEnum.Array) { throw new SerializationException(RemotingResources.SerializationObjectTypeEnum.Format(progress._objectTypeEnum.ToString())); } PRs.memberTypeEnum = MemberTypeEnum.Item; } } objectReader.Parse(PRs); }
internal void Run() { try { bool flag = true; ReadBegin(); ReadSerializationHeaderRecord(); while (flag) { BinaryHeaderEnum binaryHeaderEnum = BinaryHeaderEnum.Object; BinaryTypeEnum enum3 = expectedType; if (enum3 == BinaryTypeEnum.Primitive) { ReadMemberPrimitiveUnTyped(); } else { if (enum3 - (BinaryTypeEnum)1 > (int)BinaryTypeEnum.StringArray) { throw new SerializationException(RemotingResources.SerializationTypeExpected); } byte num = dataReader.ReadByte(); binaryHeaderEnum = (BinaryHeaderEnum)num; switch (binaryHeaderEnum) { case BinaryHeaderEnum.Object: ReadObject(); break; case BinaryHeaderEnum.ObjectWithMap: case BinaryHeaderEnum.ObjectWithMapAssemId: ReadObjectWithMap(binaryHeaderEnum); break; case BinaryHeaderEnum.ObjectWithMapTyped: case BinaryHeaderEnum.ObjectWithMapTypedAssemId: ReadObjectWithMapTyped(binaryHeaderEnum); break; case BinaryHeaderEnum.ObjectString: case BinaryHeaderEnum.CrossAppDomainString: ReadObjectString(binaryHeaderEnum); break; case BinaryHeaderEnum.Array: case BinaryHeaderEnum.ArraySinglePrimitive: case BinaryHeaderEnum.ArraySingleObject: case BinaryHeaderEnum.ArraySingleString: ReadArray(binaryHeaderEnum); break; case BinaryHeaderEnum.MemberPrimitiveTyped: ReadMemberPrimitiveTyped(); break; case BinaryHeaderEnum.MemberReference: ReadMemberReference(); break; case BinaryHeaderEnum.ObjectNull: case BinaryHeaderEnum.ObjectNullMultiple256: case BinaryHeaderEnum.ObjectNullMultiple: ReadObjectNull(binaryHeaderEnum); break; case BinaryHeaderEnum.MessageEnd: flag = false; ReadMessageEnd(); ReadEnd(); break; case BinaryHeaderEnum.Assembly: case BinaryHeaderEnum.CrossAppDomainAssembly: ReadAssembly(binaryHeaderEnum); break; case BinaryHeaderEnum.CrossAppDomainMap: ReadCrossAppDomainMap(); break; default: throw new SerializationException(RemotingResources.SerializationBinaryHeader.Format(num)); } } if (binaryHeaderEnum != BinaryHeaderEnum.Assembly) { bool next = false; while (!next) { ObjectProgress op = (ObjectProgress)stack.Peek(); if (op == null) { expectedType = BinaryTypeEnum.ObjectUrt; expectedTypeInformation = null; next = true; continue; } next = op.GetNext(out op._expectedType, out op._expectedTypeInformation); expectedType = op._expectedType; expectedTypeInformation = op._expectedTypeInformation; if (!next) { PRs.Init(); if (op._memberValueEnum == MemberValueEnum.Nested) { PRs.parseTypeEnum = ParseTypeEnum.MemberEnd; PRs.memberTypeEnum = op._memberTypeEnum; PRs.memberValueEnum = op._memberValueEnum; objectReader.Parse(PRs); } else { PRs.parseTypeEnum = ParseTypeEnum.ObjectEnd; PRs.memberTypeEnum = op._memberTypeEnum; PRs.memberValueEnum = op._memberValueEnum; objectReader.Parse(PRs); } stack.Pop(); PutOp(op); } } } } } catch (EndOfStreamException) { throw new SerializationException(RemotingResources.SerializationStreamEnd); } }
private void ReadObjectString(BinaryHeaderEnum binaryHeaderEnum) { if (_objectString == null) { _objectString = new BinaryObjectString(); } if (binaryHeaderEnum == BinaryHeaderEnum.ObjectString) { _objectString.Read(this); } else { if (_crossAppDomainString == null) { _crossAppDomainString = new BinaryCrossAppDomainString(); } _crossAppDomainString.Read(this); _objectString.Value = objectReader.CrossAppDomainArrayAt(_crossAppDomainString._value) as string; if (_objectString.Value == null) { throw new SerializationException(RemotingResources.SerializationCrossDomainError.Format(nameof(String), (int)_crossAppDomainString._value)); } _objectString.ObjectId = _crossAppDomainString._objectId; } PRs.Init(); PRs.parseTypeEnum = ParseTypeEnum.Object; PRs.objectId = objectReader.GetId((long)_objectString.ObjectId); if (PRs.objectId == topId) { PRs.objectPositionEnum = ObjectPositionEnum.Top; } PRs.objectTypeEnum = ObjectTypeEnum.Object; ObjectProgress progress = (ObjectProgress)stack.Peek(); PRs.value = _objectString.Value; PRs.keyDt = "System.String"; PRs.dtType = Converter.s_typeofString; PRs.dtTypeCode = PrimitiveTypeEnum.Invalid; PRs.varValue = _objectString.Value; if (progress == null) { PRs.parseTypeEnum = ParseTypeEnum.Object; PRs.name = "System.String"; } else { PRs.parseTypeEnum = ParseTypeEnum.Member; PRs.memberValueEnum = MemberValueEnum.InlineValue; ObjectTypeEnum ee = progress._objectTypeEnum; if (ee == ObjectTypeEnum.Object) { PRs.name = progress._name; PRs.memberTypeEnum = MemberTypeEnum.Field; } else { if (ee != ObjectTypeEnum.Array) { throw new SerializationException(RemotingResources.SerializationObjectTypeEnum.Format(progress._objectTypeEnum.ToString())); } PRs.memberTypeEnum = MemberTypeEnum.Item; } } objectReader.Parse(PRs); }