CheckRecursionStackAndPush() private method

private CheckRecursionStackAndPush ( object instance ) : void
instance object
return void
コード例 #1
0
        private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (++writer.depth > RecursionCheckDepth)
            {
                writer.CheckRecursionStackAndPush(instance);
            }
            if (writer.packedFieldNumber != 0)
            {
                throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
            }
            switch (writer.wireType)
            {
            case WireType.StartGroup:
                writer.wireType = WireType.None;
                return(new SubItemToken(-writer.fieldNumber));

            case WireType.String:
#if DEBUG
                if (writer.model != null && writer.model.ForwardsOnly)
                {
                    throw new ProtoException("Should not be buffering data");
                }
#endif
                writer.wireType = WireType.None;
                DemandSpace(32, writer);     // make some space in anticipation...
                writer.flushLock++;
                writer.position++;
                return(new SubItemToken(writer.ioIndex++));    // leave 1 space (optimistic) for length

            case WireType.Fixed32:
            {
                if (!allowFixed)
                {
                    throw CreateException(writer);
                }
                DemandSpace(32, writer);         // make some space in anticipation...
                writer.flushLock++;
                SubItemToken token = new SubItemToken(writer.ioIndex);
                ProtoWriter.IncrementedAndReset(4, writer);         // leave 4 space (rigid) for length
                return(token);
            }

            default:
                throw CreateException(writer);
            }
        }
コード例 #2
0
        // Token: 0x06000146 RID: 326 RVA: 0x0000D348 File Offset: 0x0000B548
        private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            int num = writer.depth + 1;

            writer.depth = num;
            if (num > 25)
            {
                writer.CheckRecursionStackAndPush(instance);
            }
            if (writer.packedFieldNumber != 0)
            {
                throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
            }
            switch (writer.wireType)
            {
            case WireType.String:
                writer.wireType = WireType.None;
                ProtoWriter.DemandSpace(32, writer);
                writer.flushLock++;
                writer.position++;
                num            = writer.ioIndex;
                writer.ioIndex = num + 1;
                return(new SubItemToken(num));

            case WireType.StartGroup:
                writer.wireType = WireType.None;
                return(new SubItemToken(-writer.fieldNumber));

            case WireType.Fixed32:
            {
                if (!allowFixed)
                {
                    throw ProtoWriter.CreateException(writer);
                }
                ProtoWriter.DemandSpace(32, writer);
                writer.flushLock++;
                SubItemToken result = new SubItemToken(writer.ioIndex);
                ProtoWriter.IncrementedAndReset(4, writer);
                return(result);
            }
            }
            throw ProtoWriter.CreateException(writer);
        }
コード例 #3
0
 private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
 {
     if (++writer.depth > RecursionCheckDepth)
     {
         writer.CheckRecursionStackAndPush(instance);
     }
     if(writer.packedFieldNumber != 0) throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
     switch (writer.wireType)
     {
         case WireType.StartGroup:
             writer.wireType = WireType.None;
             return new SubItemToken(-writer.fieldNumber);
         case WireType.String:
             writer.wireType = WireType.None;
             DemandSpace(32, writer); // make some space in anticipation...
             writer.flushLock++;
             writer.position++;
             return new SubItemToken(writer.ioIndex++); // leave 1 space (optimistic) for length
         case WireType.Fixed32:
             {
                 if (!allowFixed) throw CreateException(writer);
                 DemandSpace(32, writer); // make some space in anticipation...
                 writer.flushLock++;
                 SubItemToken token = new SubItemToken(writer.ioIndex);
                 ProtoWriter.IncrementedAndReset(4, writer); // leave 4 space (rigid) for length
                 return token;
             }
         default:
             throw CreateException(writer);
     }
 }
コード例 #4
0
ファイル: ProtoWriter.cs プロジェクト: floatyears/Decrypt
 private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (++writer.depth > 25)
     {
         writer.CheckRecursionStackAndPush(instance);
     }
     if (writer.packedFieldNumber != 0)
     {
         throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
     }
     switch (writer.wireType)
     {
     case WireType.String:
         writer.wireType = WireType.None;
         ProtoWriter.DemandSpace(32, writer);
         writer.flushLock++;
         writer.position++;
         return new SubItemToken(writer.ioIndex++);
     case WireType.StartGroup:
         writer.wireType = WireType.None;
         return new SubItemToken(-writer.fieldNumber);
     case WireType.Fixed32:
     {
         if (!allowFixed)
         {
             throw ProtoWriter.CreateException(writer);
         }
         ProtoWriter.DemandSpace(32, writer);
         writer.flushLock++;
         SubItemToken result = new SubItemToken(writer.ioIndex);
         ProtoWriter.IncrementedAndReset(4, writer);
         return result;
     }
     }
     throw ProtoWriter.CreateException(writer);
 }
コード例 #5
0
        private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            ProtoWriter protoWriter = writer;
            int         num         = protoWriter.depth + 1;
            int         num1        = num;

            protoWriter.depth = num;
            if (num1 > 25)
            {
                writer.CheckRecursionStackAndPush(instance);
            }
            if (writer.packedFieldNumber != 0)
            {
                throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
            }
            switch (writer.wireType)
            {
            case ProtoBuf.WireType.String:
            {
                writer.wireType = ProtoBuf.WireType.None;
                ProtoWriter.DemandSpace(32, writer);
                writer.flushLock++;
                writer.position++;
                ProtoWriter protoWriter1 = writer;
                int         num2         = protoWriter1.ioIndex;
                int         num3         = num2;
                protoWriter1.ioIndex = num2 + 1;
                return(new SubItemToken(num3));
            }

            case ProtoBuf.WireType.StartGroup:
            {
                writer.wireType = ProtoBuf.WireType.None;
                return(new SubItemToken(-writer.fieldNumber));
            }

            case ProtoBuf.WireType.EndGroup:
            {
                throw ProtoWriter.CreateException(writer);
            }

            case ProtoBuf.WireType.Fixed32:
            {
                if (!allowFixed)
                {
                    throw ProtoWriter.CreateException(writer);
                }
                ProtoWriter.DemandSpace(32, writer);
                writer.flushLock++;
                SubItemToken subItemToken = new SubItemToken(writer.ioIndex);
                ProtoWriter.IncrementedAndReset(4, writer);
                return(subItemToken);
            }

            default:
            {
                throw ProtoWriter.CreateException(writer);
            }
            }
        }