Example #1
0
        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));
            }
        }
Example #2
0
        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()));
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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));
                }
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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
                }
            }
        }
Example #7
0
 public override object CreateMap(HessianInput input) => _activator();
Example #8
0
 public override void PopulateMap(HessianInput input, object map)
 {
 }
 public override void PopulateField(HessianInput input, object obj)
 {
     _assign(obj, input.ReadObject(FieldInfo.FieldType));
 }
Example #10
0
 public abstract void PopulateField(HessianInput input, object obj);
Example #11
0
 public abstract void PopulateList(HessianInput input, IList list, int len);
Example #12
0
 public override void PopulateField(HessianInput input, object obj)
 {
     _assign(obj, _valueReader(input));
 }
Example #13
0
 public Deserializer(HessianInput input, TypeBindings typeBindings = null)
 {
     _input        = input ?? throw new ArgumentNullException(nameof(input));
     _typeBindings = typeBindings;
 }
Example #14
0
 public abstract void PopulateMap(HessianInput input, object map);
Example #15
0
 public abstract object CreateMap(HessianInput input);