comparison Implab.ServiceHost/Unity/SerializedElement.cs @ 277:963b17c275be v3

Refactoring Added <array> element to injection parameters Working on registrations of factories
author cin
date Sat, 28 Apr 2018 18:48:09 +0300
parents 6fefd5811b9b
children 8714471e8d78
comparison
equal deleted inserted replaced
276:b4e0f81c7425 277:963b17c275be
2 using System.Xml; 2 using System.Xml;
3 using System.Xml.Serialization; 3 using System.Xml.Serialization;
4 4
5 namespace Implab.ServiceHost.Unity 5 namespace Implab.ServiceHost.Unity
6 { 6 {
7 public class SerializedElement : AbstractRegistration, ISerializedValue { 7 public class SerializedElement : InstanceAbstractRegistration {
8 [XmlAttribute("href")] 8 [XmlAttribute("href")]
9 public string Location { get; set; } 9 public string Location { get; set; }
10 10
11 [XmlAttribute("serializedType")] 11 [XmlAttribute("serializedType")]
12 public string SerializedType { get; set; } 12 public string SerializedType { get; set; }
13 13
14 14
15 [XmlAnyElement] 15 [XmlAnyElement]
16 public XmlElement[] Content { get; set; } 16 public XmlElement[] Content { get; set; }
17 17
18 string ISerializedValue.TypeName { 18 public override void Visit(InstanceRegistrationBuilder builder) {
19 get { 19 base.Visit(builder);
20 return string.IsNullOrEmpty(SerializedType) ? RegistrationType : SerializedType;
21 }
22 }
23 20
24 public string TypeName => throw new NotImplementedException(); 21 var parameter = new SerializedParameterElement {
25 22 TypeName = SerializedType,
26 public override void Visit(ContainerBuilder context) { 23 Location = Location,
27 context.Visit(this); 24 Content = Content
28 } 25 };
29 26 parameter.Visit(builder.ValueBuilder);
30 public XmlReader GetReader() {
31 if (!string.IsNullOrEmpty(Location))
32 return XmlReader.Create(Location);
33 if (Content != null && Content.Length > 0)
34 return Content[0].CreateNavigator().ReadSubtree();
35
36 throw new Exception("No content found, expected XML document");
37 }
38
39 public void Visit(InjectionValueBuilder builder) {
40 throw new NotImplementedException();
41 } 27 }
42 } 28 }
43 } 29 }