Exemple #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));
            }
        }
Exemple #2
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
                }
            }
        }
Exemple #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);
            }
        }
        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 PopulateField(HessianInput input, object obj)
 {
     _assign(obj, input.ReadObject(FieldInfo.FieldType));
 }