public int AddFieldHeader(Field f)
 {
     if (!f.IsSerialised)
     {
         throw new InvalidOperationException(
             $"Field {f} is a discardable field");
     }
     var n = f.Header;
     Put(n);
     return n.Length;
 }
示例#2
0
 public bool Has(Field field)
 {
     return Fields.ContainsKey(field);
 }
 public void Add(Field field, ISerializedType value)
 {
     AddFieldHeader(field);
     if (field.IsVlEncoded)
     {
         AddLengthEncoded(value);
     }
     else
     {
         value.ToBytes(_sink);
         if (field.Type == FieldType.StObject)
         {
             AddFieldHeader(Field.ObjectEndMarker);
         }
         else if (field.Type == FieldType.StArray)
         {
             AddFieldHeader(Field.ArrayEndMarker);
         }
     }
 }