Auto status change to "Under Review"
@@ -43,8 +43,12 namespace Implab.Playground { | |||
|
43 | 43 | static void Main(string[] args) { |
|
44 | 44 | var container = new UnityContainer(); |
|
45 | 45 | |
|
46 | var ctx = new ConfigurationContext(container); | |
|
47 | ||
|
46 | 48 | var conf = SerializationHelpers.DeserializeFromFile<ContainerElement>("data/sample.xml"); |
|
47 | 49 | |
|
50 | ctx.Visit(conf); | |
|
51 | ||
|
48 | 52 | Console.WriteLine($"Registrations: {conf.Items.Count}"); |
|
49 | 53 | |
|
50 | 54 | } |
@@ -15,6 +15,18 namespace Implab.ServiceHost.Unity | |||
|
15 | 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 | 30 | public void Visit(ConfigurationContext context) { |
|
19 | 31 | context.Visit(this); |
|
20 | 32 | } |
@@ -38,6 +38,9 namespace Implab.ServiceHost.Unity { | |||
|
38 | 38 | var schema = new ConfigurationSchema(); |
|
39 | 39 | |
|
40 | 40 | schema.DefineMapping<RegisterElement>(); |
|
41 | schema.DefineMapping<IncludeElement>(); | |
|
42 | schema.DefineMapping<AssemblyElement>(); | |
|
43 | schema.DefineMapping<NamespaceElement>(); | |
|
41 | 44 | |
|
42 | 45 | return schema; |
|
43 | 46 | } |
@@ -22,7 +22,10 namespace Implab.ServiceHost.Unity { | |||
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 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 | 31 | } No newline at end of file |
@@ -9,23 +9,11 namespace Implab.ServiceHost.Unity { | |||
|
9 | 9 | public class RegisterElement : AbstractRegistration { |
|
10 | 10 | |
|
11 | 11 | /// <summary> |
|
12 | /// An optional type specification for the service registration, | |
|
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. | |
|
12 | /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. | |
|
20 | 13 | /// </summary> |
|
21 | 14 | [XmlAttribute("type")] |
|
22 | 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 | 18 | [XmlElement("constructor", typeof(ConstructorInjectionElement))] |
|
31 | 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 | 5 | namespace Implab.ServiceHost.Unity |
|
2 | 6 | { |
|
3 | public class SerializedParameterElement : InjectionParameterElement | |
|
4 | { | |
|
7 | public class SerializedParameterElement : InjectionParameterElement { | |
|
5 | 8 | |
|
9 | [XmlAnyElement] | |
|
10 | public XmlElement[] Content { get; set; } | |
|
6 | 11 | } |
|
7 | 12 | } No newline at end of file |
General Comments 3
ok, latest stable version should be in default
You need to be logged in to leave comments.
Login now