Example #1
0
        private ObjectProgress GetOp()
        {
            ObjectProgress progress;

            if (opPool == null || opPool.IsEmpty())
            {
                progress = new ObjectProgress();
            }
            else
            {
                progress = (ObjectProgress)opPool.Pop();
                progress.Init();
            }
            return(progress);
        }
Example #2
0
        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);
            }
        }