Mercurial > pub > ImplabNet
view Implab.ServiceHost/Unity/ContainerElement.cs @ 272:9d1cca834b05 v3
preview version of Unity xml configuration
author | cin |
---|---|
date | Thu, 26 Apr 2018 03:14:54 +0300 |
parents | d4d437ec4483 |
children | 79110a16cab7 |
line wrap: on
line source
using Implab.Xml; using System.Collections.Generic; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; namespace Implab.ServiceHost.Unity { [XmlRoot("container", Namespace = Schema.ContainerConfigurationNamespace)] public class ContainerElement : IXmlSerializable { public List<IConfigurationElement> Items {get; set; } = new List<IConfigurationElement>(); public XmlSchema GetSchema() { return null; } public void ReadXml(XmlReader reader) { while(reader.Read() && reader.NodeType != XmlNodeType.EndElement) { var registration = ConfigurationSchema.Default.Deserialize<IConfigurationElement>(reader); Items.Add(registration); } } public void WriteXml(XmlWriter writer) { foreach(var item in Items) { var serializer = new XmlSerializer(item.GetType()); serializer.Serialize(writer, item); } } } }