private void PutOp(ObjectProgress op) { if (opPool == null) { opPool = new SerializationStack("opPool"); } opPool.Push(op); }
private void ReadArray(BinaryHeaderEnum binaryHeaderEnum) { BinaryArray array = new BinaryArray(binaryHeaderEnum); array.Read(this); BinaryAssemblyInfo assemblyInfo; if (array._binaryTypeEnum != BinaryTypeEnum.ObjectUser) { assemblyInfo = SystemAssemblyInfo; } else { if (array._assemId < 1) { throw new SerializationException(RemotingResources.SerializationAssemblyId.Format(array._typeInformation)); } assemblyInfo = (BinaryAssemblyInfo)AssemIdToAssemblyTable[array._assemId]; } ObjectProgress op = GetOp(); ParseRecord pr = op._pr; op._objectTypeEnum = ObjectTypeEnum.Array; op._binaryTypeEnum = array._binaryTypeEnum; op._typeInformation = array._typeInformation; ObjectProgress progress2 = (ObjectProgress)stack.PeekPeek(); if (progress2 == null || array.ObjectId > 0) { op._name = "System.Array"; 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; pr.keyDt = progress2._name; pr.dtType = progress2._dtType; } else { if (ee != ObjectTypeEnum.Array) { throw new SerializationException(RemotingResources.SerializationObjectTypeEnum.Format(progress2._objectTypeEnum.ToString())); } pr.memberTypeEnum = MemberTypeEnum.Item; op._memberTypeEnum = MemberTypeEnum.Item; } } pr.objectId = objectReader.GetId((long)array.ObjectId); pr.objectPositionEnum = pr.objectId != topId ? headerId <= 0L || pr.objectId != headerId ? ObjectPositionEnum.Child : ObjectPositionEnum.Headers : ObjectPositionEnum.Top; pr.objectTypeEnum = ObjectTypeEnum.Array; BinaryTypeConverter.TypeFromInfo(array._binaryTypeEnum, array._typeInformation, objectReader, assemblyInfo, out pr.arrayElementTypeCode, out pr.arrayElementTypeString, out pr.arrayElementType, out pr.isArrayVariant); pr.dtTypeCode = PrimitiveTypeEnum.Invalid; pr.rank = array._rank; pr.lengthA = array._lengthA; pr.lowerBoundA = array._lowerBoundA; bool flag = false; switch (array._binaryArrayTypeEnum) { case BinaryArrayTypeEnum.Single: case BinaryArrayTypeEnum.SingleOffset: op._numItems = array._lengthA[0]; pr.arrayTypeEnum = ArrayTypeEnum.Single; if (Converter.IsWriteAsByteArray(pr.arrayElementTypeCode) && array._lowerBoundA[0] == 0) { flag = true; ReadArrayAsBytes(pr); } break; case BinaryArrayTypeEnum.Jagged: case BinaryArrayTypeEnum.JaggedOffset: op._numItems = array._lengthA[0]; pr.arrayTypeEnum = ArrayTypeEnum.Jagged; break; case BinaryArrayTypeEnum.Rectangular: case BinaryArrayTypeEnum.RectangularOffset: { int num = 1; int index = 0; while (true) { if (index >= array._rank) { op._numItems = num; pr.arrayTypeEnum = ArrayTypeEnum.Rectangular; break; } num *= array._lengthA[index]; index++; } break; } default: throw new SerializationException(RemotingResources.SerializationArrayType.Format(array._binaryArrayTypeEnum.ToString())); } if (!flag) { stack.Push(op); } else { PutOp(op); } objectReader.Parse(pr); if (flag) { pr.parseTypeEnum = ParseTypeEnum.ObjectEnd; objectReader.Parse(pr); } }