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 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 #3
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
                }
            }
        }