Esempio n. 1
0
        public static StObject FromParser(BinaryParser parser, int?hint = null)
        {
            var so = new StObject();

            // hint, is how many bytes to parse
            if (hint != null)
            {
                // end hint
                hint = parser.Pos() + hint;
            }

            while (!parser.End(hint))
            {
                var field = parser.ReadField();
                if (field == Field.ObjectEndMarker)
                {
                    break;
                }
                var sizeHint = field.IsVlEncoded ? parser.ReadVlLength() : (int?)null;
                var st       = field.FromParser(parser, sizeHint);
                if (st == null)
                {
                    throw new InvalidOperationException("Parsed " + field + " as null");
                }
                so.Fields[field] = st;
            }
            return(so);
        }
Esempio n. 2
0
        public static PathSet FromParser(BinaryParser parser, int?hint = null)
        {
            var  pathSet = new PathSet();
            Path path    = null;

            while (!parser.End())
            {
                byte type = parser.ReadOne();
                if (type == PathsetEndByte)
                {
                    break;
                }
                if (path == null)
                {
                    path = new Path();
                    pathSet.Add(path);
                }
                if (type == PathSeparatorByte)
                {
                    path = null;
                    continue;
                }

                AccountId account  = null;
                AccountId issuer   = null;
                Currency  currency = null;

                if ((type & PathHop.TypeAccount) != 0)
                {
                    account = AccountId.FromParser(parser);
                }
                if ((type & PathHop.TypeCurrency) != 0)
                {
                    currency = Currency.FromParser(parser);
                }
                if ((type & PathHop.TypeIssuer) != 0)
                {
                    issuer = AccountId.FromParser(parser);
                }
                var hop = new PathHop(account, issuer, currency);
                path.Add(hop);
            }
            return(pathSet);
        }
        public static StArray FromParser(BinaryParser parser, int?hint = null)
        {
            var stArray = new StArray();

            while (!parser.End())
            {
                var field = parser.ReadField();
                if (field == Field.ArrayEndMarker)
                {
                    break;
                }
                var outer = new StObject {
                    [(StObjectField)field] =
                        StObject.FromParser(parser)
                };
                stArray.Add(outer);
            }
            return(stArray);
        }
Esempio n. 4
0
 public bool End()
 {
     return(_parser.End());
 }