Beispiel #1
0
            public override StObject FromParser(BinaryParser parser, int?hint)
            {
                var so = new StObject();
                IOutTypeTranslator <ISerializedType> tr;
                ISerializedType st;
                Field           field;
                int?            sizeHint;

                while (!parser.End)
                {
                    field = parser.ReadField();
                    if (field == Field.ObjectEndMarker)
                    {
                        break;
                    }

                    tr       = OutTranslators.ForField(field);
                    sizeHint = field.IsVlEncoded() ? parser.ReadVlLength() : (int?)null;
                    st       = tr.FromParser(parser, sizeHint);
                    if (st == null)
                    {
                        throw new InvalidOperationException(string.Format("Parsed {0} as null", field));
                    }
                    so.Add(field, st);
                }

                return(Formatted(so));
            }
Beispiel #2
0
        public void Add(Field f, string s)
        {
            if (FieldSymbolics.IsSymbolicField(f))
            {
                Add(f, FieldSymbolics.AsInteger(f, s));
                return;
            }

            Add(f, OutTranslators.ForField(f).FromString(s));
        }
Beispiel #3
0
        public void Add(Field f, object value)
        {
            var             typeTranslator = OutTranslators.ForField(f);
            ISerializedType value1;

            try
            {
                value1 = typeTranslator.FromValue(value);
            }
            catch (Exception e)
            {
                throw new ApplicationException(string.Format("Couldn't add '{0}' into field '{1}\n{2}", value, f, e));
            }

            fields.Add(f, value1);
        }
Beispiel #4
0
 private void Add(Field f, byte[] bytes)
 {
     // TODO: all!!! (?)
     Add(f, OutTranslators.ForField(f).FromBytes(bytes));
 }
Beispiel #5
0
 public void Add(Field f, int i)
 {
     Add(f, OutTranslators.ForField(f).FromInteger(i));
 }