Example #1
0
        protected virtual void DeserializeDictionary <T>(DictionaryMapping mapping, T instance, TDeserializeState state)
        {
            if (IsObjectNull(state))
            {
                mapping.SetValue(instance, null);
                return;
            }

            var count      = GetCountFromState(state);
            var dictionary = CreateDictionaryFromMapping(mapping);

            mapping.SetValue(instance, dictionary);

            for (var i = 0; i < count; i++)
            {
                DeserializeDictionaryKeyValuePair(mapping, dictionary, state);
            }
        }
Example #2
0
        protected override void DeserializeDictionary <T>(DictionaryMapping mapping, T instance, XElement state)
        {
            if (IsObjectNull(state))
            {
                mapping.SetValue(instance, null);
                return;
            }

            var count      = GetCountFromState(state);
            var dictionary = CreateDictionaryFromMapping(mapping);

            mapping.SetValue(instance, dictionary);

            for (var i = 0; i < count; i++)
            {
                var keyValuePairElement = state.Elements(XmlSerializer.KeyValuePairElementName).ElementAt(i);
                DeserializeDictionaryKeyValuePair(mapping, dictionary, keyValuePairElement);
            }
        }