Exemple #1
0
        private T InternalDeserialize <T>(Type type, XElement element)
        {
            var serializer = _xmlSerializerCache.Resolve(type, element.Name.LocalName);
            var result     = serializer.Deserialize(element.CreateReader());

            return((T)result);
        }
Exemple #2
0
        private void WriteElements <T>(IList <T> elements, string section)
        {
            if (elements?.Any() != true)
            {
                return;
            }

            _xmlWriter.WriteStartElement(section);

            foreach (var element in elements)
            {
                var name       = _componentResolver.ResolveName(element.GetType());
                var serializer = _serializerCache.Resolve(element.GetType(), name);

                serializer.Serialize(_xmlWriter, element, _namespaces);
            }

            _xmlWriter.WriteEndElement();
        }