Exemplo n.º 1
0
 public void Read(out decimal target)
 {
     Expect(RawHeader.Decimal);
     target = buffer.Decimal();
     Success();
 }
Exemplo n.º 2
0
        private bool print(int depth)
        {
            var FieldSize               = RawHeader.SizeFull;
            var FieldSizeStr            = "";
            Func <RawHeader, bool> func = delegate(RawHeader expected)
            {
                var rawHeader = buffer.TrySimple(buffer.NextType(), expected);
                var hasValue  = rawHeader.HasValue;
                if (hasValue)
                {
                    FieldSize    = rawHeader.Value;
                    FieldSizeStr = ((FieldSize == RawHeader.Size1) ? ":1" : ((FieldSize == RawHeader.Size2) ? ":2" : ((FieldSize == RawHeader.Size3) ? ":3" : ((FieldSize == RawHeader.Size4) ? ":4" : ((FieldSize == RawHeader.Size5) ? ":5" : ((FieldSize == RawHeader.Size6) ? ":6" : ((FieldSize == RawHeader.SizeMask) ? ":7" : "  ")))))));
                }
                return(rawHeader.HasValue);
            };
            var  flag = buffer.EndOfBuffer();
            bool result;

            if (flag)
            {
                result = true;
            }
            else
            {
                var flag2 = func(RawHeader.CloseObject);
                if (flag2)
                {
                    print(depth, "}");
                    print(depth, "ERROR: UNEXPECTED CLOSE OF OBJECT");
                    result = false;
                }
                else
                {
                    var flag3 = func(RawHeader.CloseArray);
                    if (flag3)
                    {
                        print(depth, "]");
                        print(depth, "ERROR: UNEXPECTED CLOSE OF ARRAY");
                        result = false;
                    }
                    else
                    {
                        var flag4 = func(RawHeader.OpenObject);
                        if (flag4)
                        {
                            print(depth, "OBJECT");
                            print(depth, "{");
                            while (true)
                            {
                                var flag5 = buffer.EndOfBuffer();
                                if (flag5)
                                {
                                    break;
                                }
                                var flag6 = func(RawHeader.CloseObject);
                                if (flag6)
                                {
                                    goto Block_6;
                                }
                                var flag7 = !print(depth + 1);
                                if (flag7)
                                {
                                    goto Block_7;
                                }
                            }
                            print(depth + 1, "ERROR: UNEXPECTED END OF BUFFER");
                            result = false;
                            return(result);

Block_6:
                            print(depth, "}");
                            result = true;
                            return(result);

Block_7:
                            result = false;
                        }
                        else
                        {
                            var flag8 = func(RawHeader.OpenArray);
                            if (flag8)
                            {
                                var flag9 = buffer.EndOfBuffer();
                                if (flag9)
                                {
                                    print(depth, "ARRAY[???]");
                                    print(depth, "[");
                                    print(depth + 1, "ERROR: UNEXPECTED END OF BUFFER");
                                    result = false;
                                }
                                else
                                {
                                    var flag10 = func(RawHeader.Int32);
                                    if (flag10)
                                    {
                                        print(depth, string.Concat("ARRAY[", buffer.Int32(FieldSize), FieldSizeStr, "]"));
                                        print(depth, "[");
                                        while (true)
                                        {
                                            var flag11 = buffer.EndOfBuffer();
                                            if (flag11)
                                            {
                                                break;
                                            }
                                            var flag12 = func(RawHeader.CloseArray);
                                            if (flag12)
                                            {
                                                goto Block_12;
                                            }
                                            var flag13 = !print(depth + 1);
                                            if (flag13)
                                            {
                                                goto Block_13;
                                            }
                                        }
                                        print(depth + 1, "ERROR: UNEXPECTED END OF BUFFER");
                                        result = false;
                                        return(result);

Block_12:
                                        print(depth, "]");
                                        result = true;
                                        return(result);

Block_13:
                                        result = false;
                                    }
                                    else
                                    {
                                        print(depth, "ARRAY[???]");
                                        print(depth, "[");
                                        print(depth + 1, "ERROR: MISSING INT32 FOR ARRAY LENGHT");
                                        result = false;
                                    }
                                }
                            }
                            else
                            {
                                var flag14 = func(RawHeader.Null);
                                if (flag14)
                                {
                                    print(depth, "NULL     NULL");
                                }
                                else
                                {
                                    var flag15 = func(RawHeader.True);
                                    if (flag15)
                                    {
                                        print(depth, "BOOL     TRUE");
                                    }
                                    else
                                    {
                                        var flag16 = func(RawHeader.False);
                                        if (flag16)
                                        {
                                            print(depth, "BOOL     FALSE");
                                        }
                                        else
                                        {
                                            var flag17 = func(RawHeader.Byte);
                                            if (flag17)
                                            {
                                                print(depth, "BYTE     " + buffer.Byte());
                                            }
                                            else
                                            {
                                                var flag18 = func(RawHeader.Char);
                                                if (flag18)
                                                {
                                                    print(depth, string.Concat("CHAR", FieldSizeStr, "   '", buffer.Char(FieldSize).ToString(), "'"));
                                                }
                                                else
                                                {
                                                    var flag19 = func(RawHeader.Int16);
                                                    if (flag19)
                                                    {
                                                        print(depth, string.Concat("INT16", FieldSizeStr, "  ", buffer.Int16(FieldSize)));
                                                    }
                                                    else
                                                    {
                                                        var flag20 = func(RawHeader.UInt16);
                                                        if (flag20)
                                                        {
                                                            print(depth, string.Concat("UINT16", FieldSizeStr, " ", buffer.UInt16(FieldSize)));
                                                        }
                                                        else
                                                        {
                                                            var flag21 = func(RawHeader.Int32);
                                                            if (flag21)
                                                            {
                                                                print(depth, string.Concat("INT32", FieldSizeStr, "  ", buffer.Int32(FieldSize)));
                                                            }
                                                            else
                                                            {
                                                                var flag22 = func(RawHeader.UInt32);
                                                                if (flag22)
                                                                {
                                                                    print(depth, string.Concat("UINT32", FieldSizeStr, " ", buffer.UInt32(FieldSize)));
                                                                }
                                                                else
                                                                {
                                                                    var flag23 = func(RawHeader.Int64);
                                                                    if (flag23)
                                                                    {
                                                                        print(depth, string.Concat("INT64", FieldSizeStr, "  ", buffer.Int64(FieldSize)));
                                                                    }
                                                                    else
                                                                    {
                                                                        var flag24 = func(RawHeader.UInt64);
                                                                        if (flag24)
                                                                        {
                                                                            print(depth, string.Concat("UINT64", FieldSizeStr, " ", buffer.UInt64(FieldSize)));
                                                                        }
                                                                        else
                                                                        {
                                                                            var flag25 = func(RawHeader.Single);
                                                                            if (flag25)
                                                                            {
                                                                                print(depth, "SINGLE   " + buffer.Single());
                                                                            }
                                                                            else
                                                                            {
                                                                                var flag26 = func(RawHeader.Double);
                                                                                if (flag26)
                                                                                {
                                                                                    print(depth, "DOUBLE   " + buffer.Double());
                                                                                }
                                                                                else
                                                                                {
                                                                                    var flag27 = func(RawHeader.Decimal);
                                                                                    if (flag27)
                                                                                    {
                                                                                        print(depth, "DECIMAL  " + buffer.Decimal());
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        var flag28 = func(RawHeader.DateTime);
                                                                                        if (flag28)
                                                                                        {
                                                                                            print(depth, "DATETIME " + buffer.DateTime());
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            var flag29 = func(RawHeader.Time);
                                                                                            if (flag29)
                                                                                            {
                                                                                                print(depth, string.Concat("TIME", FieldSizeStr, "   ", buffer.Time(FieldSize)));
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                var flag30 = func(RawHeader.Guid);
                                                                                                if (flag30)
                                                                                                {
                                                                                                    print(depth, "GUID     " + buffer.Guid());
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    var flag31 = func(RawHeader.String);
                                                                                                    if (flag31)
                                                                                                    {
                                                                                                        print(depth, string.Concat("STRING", FieldSizeStr, " \"", buffer.String(FieldSize), "\""));
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        var flag32 = func(RawHeader.ByteArray);
                                                                                                        if (!flag32)
                                                                                                        {
                                                                                                            print(depth, "ERROR: UNEXPECTED TYPE HEADER " + buffer.NextType());
                                                                                                            result = false;
                                                                                                            return(result);
                                                                                                        }
                                                                                                        var array    = buffer.Bytes(FieldSize);
                                                                                                        var expr_782 = new object[5];
                                                                                                        expr_782[0] = "BYTE[";
                                                                                                        expr_782[1] = array.Length;
                                                                                                        expr_782[2] = FieldSizeStr;
                                                                                                        expr_782[3] = "] ";
                                                                                                        var arg_7D9_1 = 4;
                                                                                                        var arg_7D4_0 = " ";
                                                                                                        expr_782[arg_7D9_1] = string.Join(arg_7D4_0, array.Select(b => b.ToString("X02")));
                                                                                                        print(depth, string.Concat(expr_782));
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                result = true;
                            }
                        }
                    }
                }
            }
            return(result);
        }