private GetNext ( BinaryTypeEnum &outBinaryTypeEnum, Object &outTypeInformation ) : bool | ||
outBinaryTypeEnum | BinaryTypeEnum | |
outTypeInformation | Object | |
return | bool |
// Parse the input // Reads each record from the input stream. If the record is a primitive type (A number) // then it doesn't have a BinaryHeaderEnum byte. For this case the expected type // has been previously set to Primitive internal void Run() { try { bool isLoop = true; ReadBegin(); ReadSerializationHeaderRecord(); while (isLoop) { BinaryHeaderEnum binaryHeaderEnum = BinaryHeaderEnum.Object; switch (_expectedType) { case BinaryTypeEnum.ObjectUrt: case BinaryTypeEnum.ObjectUser: case BinaryTypeEnum.String: case BinaryTypeEnum.Object: case BinaryTypeEnum.ObjectArray: case BinaryTypeEnum.StringArray: case BinaryTypeEnum.PrimitiveArray: byte inByte = _dataReader.ReadByte(); binaryHeaderEnum = (BinaryHeaderEnum)inByte; switch (binaryHeaderEnum) { case BinaryHeaderEnum.Assembly: case BinaryHeaderEnum.CrossAppDomainAssembly: ReadAssembly(binaryHeaderEnum); break; case BinaryHeaderEnum.Object: ReadObject(); break; case BinaryHeaderEnum.CrossAppDomainMap: ReadCrossAppDomainMap(); 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: isLoop = false; ReadMessageEnd(); ReadEnd(); break; default: throw new SerializationException(SR.Format(SR.Serialization_BinaryHeader, inByte)); } break; case BinaryTypeEnum.Primitive: ReadMemberPrimitiveUnTyped(); break; default: throw new SerializationException(SR.Serialization_TypeExpected); } // If an assembly is encountered, don't advance // object Progress, if (binaryHeaderEnum != BinaryHeaderEnum.Assembly) { // End of parse loop. bool isData = false; // Set up loop for next iteration. // If this is an object, and the end of object has been reached, then parse object end. while (!isData) { ObjectProgress op = (ObjectProgress)_stack.Peek(); if (op == null) { // No more object on stack, then the next record is a top level object _expectedType = BinaryTypeEnum.ObjectUrt; _expectedTypeInformation = null; isData = true; } else { // Find out what record is expected next isData = op.GetNext(out op._expectedType, out op._expectedTypeInformation); _expectedType = op._expectedType; _expectedTypeInformation = op._expectedTypeInformation; if (!isData) { // No record is expected next, this is the end of an object or array PRs.Init(); if (op._memberValueEnum == InternalMemberValueE.Nested) { // Nested object PRs._parseTypeEnum = InternalParseTypeE.MemberEnd; PRs._memberTypeEnum = op._memberTypeEnum; PRs._memberValueEnum = op._memberValueEnum; _objectReader.Parse(PRs); } else { // Top level object PRs._parseTypeEnum = InternalParseTypeE.ObjectEnd; PRs._memberTypeEnum = op._memberTypeEnum; PRs._memberValueEnum = op._memberValueEnum; _objectReader.Parse(PRs); } _stack.Pop(); PutOp(op); } } } } } } catch (EndOfStreamException) { // EOF should never be thrown since there is a MessageEnd record to stop parsing throw new SerializationException(SR.Serialization_StreamEnd); } }
internal void Run() { try { bool flag = true; this.ReadBegin(); this.ReadSerializationHeaderRecord(); while (flag) { byte num; BinaryHeaderEnum binaryHeaderEnum = BinaryHeaderEnum.Object; switch (this.expectedType) { case BinaryTypeEnum.Primitive: this.ReadMemberPrimitiveUnTyped(); goto Label_0177; case BinaryTypeEnum.String: case BinaryTypeEnum.Object: case BinaryTypeEnum.ObjectUrt: case BinaryTypeEnum.ObjectUser: case BinaryTypeEnum.ObjectArray: case BinaryTypeEnum.StringArray: case BinaryTypeEnum.PrimitiveArray: num = this.dataReader.ReadByte(); binaryHeaderEnum = (BinaryHeaderEnum)num; switch (binaryHeaderEnum) { case BinaryHeaderEnum.Object: goto Label_00C9; case BinaryHeaderEnum.ObjectWithMap: case BinaryHeaderEnum.ObjectWithMapAssemId: goto Label_00DF; case BinaryHeaderEnum.ObjectWithMapTyped: case BinaryHeaderEnum.ObjectWithMapTypedAssemId: goto Label_00EB; case BinaryHeaderEnum.ObjectString: case BinaryHeaderEnum.CrossAppDomainString: goto Label_0100; case BinaryHeaderEnum.Array: case BinaryHeaderEnum.ArraySinglePrimitive: case BinaryHeaderEnum.ArraySingleObject: case BinaryHeaderEnum.ArraySingleString: goto Label_0109; case BinaryHeaderEnum.MemberPrimitiveTyped: goto Label_0112; case BinaryHeaderEnum.MemberReference: goto Label_011A; case BinaryHeaderEnum.ObjectNull: case BinaryHeaderEnum.ObjectNullMultiple256: case BinaryHeaderEnum.ObjectNullMultiple: goto Label_0122; case BinaryHeaderEnum.MessageEnd: goto Label_012B; case BinaryHeaderEnum.CrossAppDomainMap: goto Label_00D4; case BinaryHeaderEnum.MethodCall: case BinaryHeaderEnum.MethodReturn: goto Label_00F7; } goto Label_013B; default: throw new SerializationException(Environment.GetResourceString("Serialization_TypeExpected")); } this.ReadAssembly(binaryHeaderEnum); goto Label_0177; Label_00C9: this.ReadObject(); goto Label_0177; Label_00D4: this.ReadCrossAppDomainMap(); goto Label_0177; Label_00DF: this.ReadObjectWithMap(binaryHeaderEnum); goto Label_0177; Label_00EB: this.ReadObjectWithMapTyped(binaryHeaderEnum); goto Label_0177; Label_00F7: this.ReadMethodObject(binaryHeaderEnum); goto Label_0177; Label_0100: this.ReadObjectString(binaryHeaderEnum); goto Label_0177; Label_0109: this.ReadArray(binaryHeaderEnum); goto Label_0177; Label_0112: this.ReadMemberPrimitiveTyped(); goto Label_0177; Label_011A: this.ReadMemberReference(); goto Label_0177; Label_0122: this.ReadObjectNull(binaryHeaderEnum); goto Label_0177; Label_012B: flag = false; this.ReadMessageEnd(); this.ReadEnd(); goto Label_0177; Label_013B :; throw new SerializationException(Environment.GetResourceString("Serialization_BinaryHeader", new object[] { num })); Label_0177: if (binaryHeaderEnum != BinaryHeaderEnum.Assembly) { bool next = false; while (!next) { ObjectProgress op = (ObjectProgress)this.stack.Peek(); if (op == null) { this.expectedType = BinaryTypeEnum.ObjectUrt; this.expectedTypeInformation = null; next = true; } else { next = op.GetNext(out op.expectedType, out op.expectedTypeInformation); this.expectedType = op.expectedType; this.expectedTypeInformation = op.expectedTypeInformation; if (!next) { this.prs.Init(); if (op.memberValueEnum == InternalMemberValueE.Nested) { this.prs.PRparseTypeEnum = InternalParseTypeE.MemberEnd; this.prs.PRmemberTypeEnum = op.memberTypeEnum; this.prs.PRmemberValueEnum = op.memberValueEnum; this.objectReader.Parse(this.prs); } else { this.prs.PRparseTypeEnum = InternalParseTypeE.ObjectEnd; this.prs.PRmemberTypeEnum = op.memberTypeEnum; this.prs.PRmemberValueEnum = op.memberValueEnum; this.objectReader.Parse(this.prs); } this.stack.Pop(); this.PutOp(op); } } } } } } catch (EndOfStreamException) { throw new SerializationException(Environment.GetResourceString("Serialization_StreamEnd")); } }
internal void Run() { try { bool flag1 = true; this.ReadBegin(); this.ReadSerializationHeaderRecord(); while (flag1) { BinaryHeaderEnum binaryHeaderEnum = BinaryHeaderEnum.Object; switch (this.expectedType) { case BinaryTypeEnum.Primitive: this.ReadMemberPrimitiveUnTyped(); break; case BinaryTypeEnum.String: case BinaryTypeEnum.Object: case BinaryTypeEnum.ObjectUrt: case BinaryTypeEnum.ObjectUser: case BinaryTypeEnum.ObjectArray: case BinaryTypeEnum.StringArray: case BinaryTypeEnum.PrimitiveArray: byte num = this.dataReader.ReadByte(); binaryHeaderEnum = (BinaryHeaderEnum)num; switch (binaryHeaderEnum) { case BinaryHeaderEnum.Object: this.ReadObject(); break; case BinaryHeaderEnum.ObjectWithMap: case BinaryHeaderEnum.ObjectWithMapAssemId: this.ReadObjectWithMap(binaryHeaderEnum); break; case BinaryHeaderEnum.ObjectWithMapTyped: case BinaryHeaderEnum.ObjectWithMapTypedAssemId: this.ReadObjectWithMapTyped(binaryHeaderEnum); break; case BinaryHeaderEnum.ObjectString: case BinaryHeaderEnum.CrossAppDomainString: this.ReadObjectString(binaryHeaderEnum); break; case BinaryHeaderEnum.Array: case BinaryHeaderEnum.ArraySinglePrimitive: case BinaryHeaderEnum.ArraySingleObject: case BinaryHeaderEnum.ArraySingleString: this.ReadArray(binaryHeaderEnum); break; case BinaryHeaderEnum.MemberPrimitiveTyped: this.ReadMemberPrimitiveTyped(); break; case BinaryHeaderEnum.MemberReference: this.ReadMemberReference(); break; case BinaryHeaderEnum.ObjectNull: case BinaryHeaderEnum.ObjectNullMultiple256: case BinaryHeaderEnum.ObjectNullMultiple: this.ReadObjectNull(binaryHeaderEnum); break; case BinaryHeaderEnum.MessageEnd: flag1 = false; this.ReadMessageEnd(); this.ReadEnd(); break; case BinaryHeaderEnum.Assembly: case BinaryHeaderEnum.CrossAppDomainAssembly: this.ReadAssembly(binaryHeaderEnum); break; case BinaryHeaderEnum.CrossAppDomainMap: this.ReadCrossAppDomainMap(); break; case BinaryHeaderEnum.MethodCall: case BinaryHeaderEnum.MethodReturn: this.ReadMethodObject(binaryHeaderEnum); break; default: throw new SerializationException(Environment.GetResourceString("Serialization_BinaryHeader", (object)num)); } default: throw new SerializationException(Environment.GetResourceString("Serialization_TypeExpected")); } if (binaryHeaderEnum != BinaryHeaderEnum.Assembly) { bool flag2 = false; while (!flag2) { ObjectProgress op = (ObjectProgress)this.stack.Peek(); if (op == null) { this.expectedType = BinaryTypeEnum.ObjectUrt; this.expectedTypeInformation = (object)null; flag2 = true; } else { ObjectProgress objectProgress = op; // ISSUE: explicit reference operation // ISSUE: variable of a reference type BinaryTypeEnum& outBinaryTypeEnum = @objectProgress.expectedType; // ISSUE: explicit reference operation // ISSUE: variable of a reference type object& outTypeInformation = @op.expectedTypeInformation; flag2 = objectProgress.GetNext(outBinaryTypeEnum, outTypeInformation); this.expectedType = op.expectedType; this.expectedTypeInformation = op.expectedTypeInformation; if (!flag2) { this.prs.Init(); if (op.memberValueEnum == InternalMemberValueE.Nested) { this.prs.PRparseTypeEnum = InternalParseTypeE.MemberEnd; this.prs.PRmemberTypeEnum = op.memberTypeEnum; this.prs.PRmemberValueEnum = op.memberValueEnum; this.objectReader.Parse(this.prs); } else { this.prs.PRparseTypeEnum = InternalParseTypeE.ObjectEnd; this.prs.PRmemberTypeEnum = op.memberTypeEnum; this.prs.PRmemberValueEnum = op.memberValueEnum; this.objectReader.Parse(this.prs); } this.stack.Pop(); this.PutOp(op); } } } } } } catch (EndOfStreamException ex) { throw new SerializationException(Environment.GetResourceString("Serialization_StreamEnd")); } }
/* * Parse the input * Reads each record from the input stream. If the record is a primitive type (A number) * then it doesn't have a BinaryHeaderEnum byte. For this case the expected type * has been previously set to Primitive * @internalonly */ internal void Run() { try { bool isLoop = true; ReadBegin(); ReadSerializationHeaderRecord(); while (isLoop) { SerTrace.Log(this, "Run loop ", ((Enum)expectedType).ToString()); BinaryHeaderEnum binaryHeaderEnum = BinaryHeaderEnum.Object; switch (expectedType) { case BinaryTypeEnum.ObjectUrt: case BinaryTypeEnum.ObjectUser: case BinaryTypeEnum.String: case BinaryTypeEnum.Object: case BinaryTypeEnum.ObjectArray: case BinaryTypeEnum.StringArray: case BinaryTypeEnum.PrimitiveArray: Byte inByte = dataReader.ReadByte(); binaryHeaderEnum = (BinaryHeaderEnum)inByte; //Console.WriteLine("Beginning of loop "+((Enum)binaryHeaderEnum).ToString()); switch (binaryHeaderEnum) { case BinaryHeaderEnum.Assembly: case BinaryHeaderEnum.CrossAppDomainAssembly: ReadAssembly(binaryHeaderEnum); break; case BinaryHeaderEnum.Object: ReadObject(); break; case BinaryHeaderEnum.CrossAppDomainMap: ReadCrossAppDomainMap(); break; case BinaryHeaderEnum.ObjectWithMap: case BinaryHeaderEnum.ObjectWithMapAssemId: ReadObjectWithMap(binaryHeaderEnum); break; case BinaryHeaderEnum.ObjectWithMapTyped: case BinaryHeaderEnum.ObjectWithMapTypedAssemId: ReadObjectWithMapTyped(binaryHeaderEnum); break; case BinaryHeaderEnum.MethodCall: case BinaryHeaderEnum.MethodReturn: ReadMethodObject(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: isLoop = false; ReadMessageEnd(); ReadEnd(); break; default: throw new SerializationException(String.Format(Environment.GetResourceString("Serialization_BinaryHeader"), inByte)); } break; case BinaryTypeEnum.Primitive: ReadMemberPrimitiveUnTyped(); break; default: throw new SerializationException(Environment.GetResourceString("Serialization_TypeExpected")); } // If an assembly is encountered, don't advance // object Progress, if (binaryHeaderEnum != BinaryHeaderEnum.Assembly) { // End of parse loop. bool isData = false; // Set up loop for next iteration. // If this is an object, and the end of object has been reached, then parse object end. while (!isData) { ObjectProgress op = (ObjectProgress)stack.Peek(); if (op == null) { // No more object on stack, then the next record is a top level object SerTrace.Log(this, "Run loop op null, top level object"); expectedType = BinaryTypeEnum.ObjectUrt; expectedTypeInformation = null; isData = true; } else { SerTrace.Log(this, "Run loop op not null, continue object"); // Find out what record is expected next isData = op.GetNext(out op.expectedType, out op.expectedTypeInformation); expectedType = op.expectedType; expectedTypeInformation = op.expectedTypeInformation; SerTrace.Log(this, "Run loop opName ", op.name, ", expectedType ", ((Enum)expectedType).ToString(), " expectedTypeInformation, ", expectedTypeInformation); SerTrace.Log(this, "Run ", isData); if (!isData) { // No record is expected next, this is the end of an object or array SerTrace.Log(this, "Run End of Object "); stack.Dump(); prs.Init(); if (op.memberValueEnum == InternalMemberValueE.Nested) { // Nested object prs.PRparseTypeEnum = InternalParseTypeE.MemberEnd; prs.PRmemberTypeEnum = op.memberTypeEnum; prs.PRmemberValueEnum = op.memberValueEnum; objectReader.Parse(prs); } else { // Top level object prs.PRparseTypeEnum = InternalParseTypeE.ObjectEnd; prs.PRmemberTypeEnum = op.memberTypeEnum; prs.PRmemberValueEnum = op.memberValueEnum; objectReader.Parse(prs); } stack.Pop(); PutOp(op); } } } } } } catch (EndOfStreamException) { // EOF should never be thrown since there is a MessageEnd record to stop parsing BCLDebug.Trace("BINARY", "\n*****EOF*************************\n"); throw new SerializationException(Environment.GetResourceString("Serialization_StreamEnd")); } }