public override void PopulateMap(HessianInput input, object map) { var dict = (IDictionary)map; // NOTE potential boxing here; probably not worth figuring out how to avoid while (!input.IsEnd()) { dict.Add(input.ReadObject(KeyType), input.ReadObject(ValueType)); } }
public override object CreateMap(HessianInput input) { if (!isCompact) { if (input.ReadString() != "name") { throw new Exception("Not a valid enum"); } } return(Enum.Parse(MapType, input.ReadString())); }
public override void PopulateField(HessianInput input, object obj) { if (obj is Exception ex) { var fieldValue = input.ReadObject(FieldInfo.FieldType); if (fieldValue is Exception inner && InnerContainsEx(ex, inner)) { // we cannot assign inner exception if it already contains ex. // This would give us a cycle in _innerException that crashes .Net. return; } _assign(obj, fieldValue); } else { base.PopulateField(input, obj); } }
public override void PopulateList(HessianInput input, IList list, int len) { var typedCollection = (ICollection <T>)list; if (len >= 0) { for (var i = 0; i < len; i++) { typedCollection.Add(_valueReader(input)); } } else { while (!input.IsEnd()) { typedCollection.Add(_valueReader(input)); } } }
public override void PopulateList(HessianInput input, IList list, int length) { if (input is null) { throw new ArgumentNullException(nameof(input)); } if (list is null) { throw new ArgumentNullException(nameof(list)); } if (length < 0) { throw new ArgumentOutOfRangeException("length is less than zero.", nameof(length)); } for (int i = 0; i < length; i++) { list[i] = input.ReadObject(ElementType); } }
public override void PopulateMap(HessianInput input, object map) { if (_definedFields != null) { // compact foreach (var fieldDeserializer in _definedFields) { if (fieldDeserializer != null) { fieldDeserializer.PopulateField(input, map); } else { input.ReadObject(); // ignore value } } } else { // read key / value tuples while (!input.IsEnd()) { var key = input.ReadObject(); if (key is string fieldName) { var fieldDeserializer = GetFieldDeserializer(fieldName); if (fieldDeserializer != null) { fieldDeserializer.PopulateField(input, map); continue; // next } } input.ReadObject(); // ignore value } } }
public override object CreateMap(HessianInput input) => _activator();
public override void PopulateMap(HessianInput input, object map) { }
public override void PopulateField(HessianInput input, object obj) { _assign(obj, input.ReadObject(FieldInfo.FieldType)); }
public abstract void PopulateField(HessianInput input, object obj);
public abstract void PopulateList(HessianInput input, IList list, int len);
public override void PopulateField(HessianInput input, object obj) { _assign(obj, _valueReader(input)); }
public Deserializer(HessianInput input, TypeBindings typeBindings = null) { _input = input ?? throw new ArgumentNullException(nameof(input)); _typeBindings = typeBindings; }
public abstract void PopulateMap(HessianInput input, object map);
public abstract object CreateMap(HessianInput input);