##// END OF EJS Templates
Working on Unity xml configuration
cin -
r271:d4d437ec4483 v3
parent child
Show More
@@ -43,8 +43,12 namespace Implab.Playground {
43 static void Main(string[] args) {
43 static void Main(string[] args) {
44 var container = new UnityContainer();
44 var container = new UnityContainer();
45
45
46 var ctx = new ConfigurationContext(container);
47
46 var conf = SerializationHelpers.DeserializeFromFile<ContainerElement>("data/sample.xml");
48 var conf = SerializationHelpers.DeserializeFromFile<ContainerElement>("data/sample.xml");
47
49
50 ctx.Visit(conf);
51
48 Console.WriteLine($"Registrations: {conf.Items.Count}");
52 Console.WriteLine($"Registrations: {conf.Items.Count}");
49
53
50 }
54 }
@@ -15,6 +15,18 namespace Implab.ServiceHost.Unity
15 get; set;
15 get; set;
16 }
16 }
17
17
18 [XmlElement("signleton", typeof(SimgletonLifetimeElement))]
19 [XmlElement("context", typeof(ContextLifetimeElement))]
20 [XmlElement("container", typeof(ContainerLifetimeElement))]
21 [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))]
22 public LifetimeElement Lifetime {get; set;}
23
24 /// <summary>
25 /// A type specification for the service registration,
26 /// </summary>
27 [XmlAttribute("provides")]
28 public string ProvidesType { get; set; }
29
18 public void Visit(ConfigurationContext context) {
30 public void Visit(ConfigurationContext context) {
19 context.Visit(this);
31 context.Visit(this);
20 }
32 }
@@ -38,6 +38,9 namespace Implab.ServiceHost.Unity {
38 var schema = new ConfigurationSchema();
38 var schema = new ConfigurationSchema();
39
39
40 schema.DefineMapping<RegisterElement>();
40 schema.DefineMapping<RegisterElement>();
41 schema.DefineMapping<IncludeElement>();
42 schema.DefineMapping<AssemblyElement>();
43 schema.DefineMapping<NamespaceElement>();
41
44
42 return schema;
45 return schema;
43 }
46 }
@@ -22,7 +22,10 namespace Implab.ServiceHost.Unity {
22 }
22 }
23
23
24 public void WriteXml(XmlWriter writer) {
24 public void WriteXml(XmlWriter writer) {
25 throw new System.NotImplementedException();
25 foreach(var item in Items) {
26 var serializer = new XmlSerializer(item.GetType());
27 serializer.Serialize(writer, item);
28 }
26 }
29 }
27 }
30 }
28 } No newline at end of file
31 }
@@ -9,23 +9,11 namespace Implab.ServiceHost.Unity {
9 public class RegisterElement : AbstractRegistration {
9 public class RegisterElement : AbstractRegistration {
10
10
11 /// <summary>
11 /// <summary>
12 /// An optional type specification for the service registration,
12 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">.
13 /// must be assignable from the type specified by <see cref="ImplementedType"/>
14 /// </summary>
15 [XmlAttribute("provides")]
16 public string ProvidesType { get; set; }
17
18 /// <summary>
19 /// The type which is registered as a service in the container.
20 /// </summary>
13 /// </summary>
21 [XmlAttribute("type")]
14 [XmlAttribute("type")]
22 public string ImplementedType { get; set; }
15 public string ImplementedType { get; set; }
23
16
24 [XmlElement("signleton", typeof(SimgletonLifetimeElement))]
25 [XmlElement("context", typeof(ContextLifetimeElement))]
26 [XmlElement("container", typeof(ContainerLifetimeElement))]
27 [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))]
28 public LifetimeElement Lifetime {get; set;}
29
17
30 [XmlElement("constructor", typeof(ConstructorInjectionElement))]
18 [XmlElement("constructor", typeof(ConstructorInjectionElement))]
31 [XmlElement("property", typeof(PropertyInjectionElement))]
19 [XmlElement("property", typeof(PropertyInjectionElement))]
@@ -1,7 +1,12
1 using System.Xml;
2 using System.Xml.Schema;
3 using System.Xml.Serialization;
4
1 namespace Implab.ServiceHost.Unity
5 namespace Implab.ServiceHost.Unity
2 {
6 {
3 public class SerializedParameterElement : InjectionParameterElement
7 public class SerializedParameterElement : InjectionParameterElement {
4 {
5
8
9 [XmlAnyElement]
10 public XmlElement[] Content { get; set; }
6 }
11 }
7 } No newline at end of file
12 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now