Mercurial > pub > ImplabNet
comparison Implab.ServiceHost/Unity/ContainerElement.cs @ 273:79110a16cab7 v3
Working on Unity xml configuration: Refactoring in progress
| author | cin |
|---|---|
| date | Thu, 26 Apr 2018 19:35:01 +0300 |
| parents | d4d437ec4483 |
| children | 22629bf26121 |
comparison
equal
deleted
inserted
replaced
| 272:9d1cca834b05 | 273:79110a16cab7 |
|---|---|
| 4 using System.Xml.Schema; | 4 using System.Xml.Schema; |
| 5 using System.Xml.Serialization; | 5 using System.Xml.Serialization; |
| 6 | 6 |
| 7 namespace Implab.ServiceHost.Unity { | 7 namespace Implab.ServiceHost.Unity { |
| 8 [XmlRoot("container", Namespace = Schema.ContainerConfigurationNamespace)] | 8 [XmlRoot("container", Namespace = Schema.ContainerConfigurationNamespace)] |
| 9 public class ContainerElement : IXmlSerializable { | 9 public class ContainerElement : ContainerItemElement { |
| 10 | 10 |
| 11 public List<IConfigurationElement> Items {get; set; } = new List<IConfigurationElement>(); | 11 public List<ContainerItemElement> Items {get; set; } = new List<ContainerItemElement>(); |
| 12 | 12 |
| 13 public XmlSchema GetSchema() { | 13 public override void Visit(ContainerContext context) { |
| 14 return null; | 14 context.Visit(this); |
| 15 } | |
| 16 | |
| 17 public void ReadXml(XmlReader reader) { | |
| 18 while(reader.Read() && reader.NodeType != XmlNodeType.EndElement) { | |
| 19 var registration = ConfigurationSchema.Default.Deserialize<IConfigurationElement>(reader); | |
| 20 Items.Add(registration); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 public void WriteXml(XmlWriter writer) { | |
| 25 foreach(var item in Items) { | |
| 26 var serializer = new XmlSerializer(item.GetType()); | |
| 27 serializer.Serialize(writer, item); | |
| 28 } | |
| 29 } | 15 } |
| 30 } | 16 } |
| 31 } | 17 } |
