# HG changeset patch # User cin # Date 1524673415 -10800 # Node ID d4d437ec4483e2f9a507c72374c93244bde1ba45 # Parent ade80d94dfb5f48e774c6dabb16645cc617d928a Working on Unity xml configuration diff -r ade80d94dfb5 -r d4d437ec4483 Implab.Playground/Program.cs --- a/Implab.Playground/Program.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.Playground/Program.cs Wed Apr 25 19:23:35 2018 +0300 @@ -43,8 +43,12 @@ static void Main(string[] args) { var container = new UnityContainer(); + var ctx = new ConfigurationContext(container); + var conf = SerializationHelpers.DeserializeFromFile("data/sample.xml"); + ctx.Visit(conf); + Console.WriteLine($"Registrations: {conf.Items.Count}"); } diff -r ade80d94dfb5 -r d4d437ec4483 Implab.ServiceHost/Unity/AbstractRegistration.cs --- a/Implab.ServiceHost/Unity/AbstractRegistration.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.ServiceHost/Unity/AbstractRegistration.cs Wed Apr 25 19:23:35 2018 +0300 @@ -15,6 +15,18 @@ get; set; } + [XmlElement("signleton", typeof(SimgletonLifetimeElement))] + [XmlElement("context", typeof(ContextLifetimeElement))] + [XmlElement("container", typeof(ContainerLifetimeElement))] + [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))] + public LifetimeElement Lifetime {get; set;} + + /// + /// A type specification for the service registration, + /// + [XmlAttribute("provides")] + public string ProvidesType { get; set; } + public void Visit(ConfigurationContext context) { context.Visit(this); } diff -r ade80d94dfb5 -r d4d437ec4483 Implab.ServiceHost/Unity/ConfigurationSchema.cs --- a/Implab.ServiceHost/Unity/ConfigurationSchema.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.ServiceHost/Unity/ConfigurationSchema.cs Wed Apr 25 19:23:35 2018 +0300 @@ -38,6 +38,9 @@ var schema = new ConfigurationSchema(); schema.DefineMapping(); + schema.DefineMapping(); + schema.DefineMapping(); + schema.DefineMapping(); return schema; } diff -r ade80d94dfb5 -r d4d437ec4483 Implab.ServiceHost/Unity/ContainerElement.cs --- a/Implab.ServiceHost/Unity/ContainerElement.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.ServiceHost/Unity/ContainerElement.cs Wed Apr 25 19:23:35 2018 +0300 @@ -22,7 +22,10 @@ } public void WriteXml(XmlWriter writer) { - throw new System.NotImplementedException(); + foreach(var item in Items) { + var serializer = new XmlSerializer(item.GetType()); + serializer.Serialize(writer, item); + } } } } \ No newline at end of file diff -r ade80d94dfb5 -r d4d437ec4483 Implab.ServiceHost/Unity/RegisterElement.cs --- a/Implab.ServiceHost/Unity/RegisterElement.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.ServiceHost/Unity/RegisterElement.cs Wed Apr 25 19:23:35 2018 +0300 @@ -9,23 +9,11 @@ public class RegisterElement : AbstractRegistration { /// - /// An optional type specification for the service registration, - /// must be assignable from the type specified by - /// - [XmlAttribute("provides")] - public string ProvidesType { get; set; } - - /// - /// The type which is registered as a service in the container. + /// An optional type which is registered as a service in the container, must be assignable to . /// [XmlAttribute("type")] public string ImplementedType { get; set; } - [XmlElement("signleton", typeof(SimgletonLifetimeElement))] - [XmlElement("context", typeof(ContextLifetimeElement))] - [XmlElement("container", typeof(ContainerLifetimeElement))] - [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))] - public LifetimeElement Lifetime {get; set;} [XmlElement("constructor", typeof(ConstructorInjectionElement))] [XmlElement("property", typeof(PropertyInjectionElement))] diff -r ade80d94dfb5 -r d4d437ec4483 Implab.ServiceHost/Unity/SerializedParameterElement.cs --- a/Implab.ServiceHost/Unity/SerializedParameterElement.cs Wed Apr 25 04:44:40 2018 +0300 +++ b/Implab.ServiceHost/Unity/SerializedParameterElement.cs Wed Apr 25 19:23:35 2018 +0300 @@ -1,7 +1,12 @@ +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; + namespace Implab.ServiceHost.Unity { - public class SerializedParameterElement : InjectionParameterElement - { - + public class SerializedParameterElement : InjectionParameterElement { + + [XmlAnyElement] + public XmlElement[] Content { get; set; } } } \ No newline at end of file