##// END OF EJS Templates
refactoring
cin -
r275:6fefd5811b9b v3
parent child
Show More
@@ -0,0 +1,12
1 using System.Collections.Generic;
2
3 namespace Implab.ServiceHost.Unity
4 {
5 public interface IArrayInjectionParameter {
6
7 string TypeName { get; }
8
9 IEnumerable<IInjectionParameter> Items { get; }
10
11 }
12 } No newline at end of file
@@ -0,0 +1,5
1 namespace Implab.ServiceHost.Unity {
2 public interface IInjectionParameter {
3 void Visit(InjectionValueBuilder builder);
4 }
5 } No newline at end of file
@@ -1,12 +1,12
1 namespace Implab.ServiceHost.Unity
1 namespace Implab.ServiceHost.Unity
2 {
2 {
3 public class DefaultParameterElement : InjectionParameterElement, ITextValue {
3 public class DefaultParameterElement : InjectionParameterElement, ITextValue {
4 public string Value {
4 public string Value {
5 get { return null; }
5 get { return null; }
6 }
6 }
7
7
8 internal override void Visit(InjectionValueBuilder builder) {
8 public override void Visit(InjectionValueBuilder builder) {
9 builder.Visit(this);
9 builder.Visit(this);
10 }
10 }
11 }
11 }
12 } No newline at end of file
12 }
@@ -1,16 +1,16
1 using System.Xml.Serialization;
1 using System.Xml.Serialization;
2
2
3 namespace Implab.ServiceHost.Unity {
3 namespace Implab.ServiceHost.Unity {
4 public class DependencyParameterElement : InjectionParameterElement, IDependencyReference {
4 public class DependencyParameterElement : InjectionParameterElement, IDependencyReference {
5
5
6 [XmlAttribute("name")]
6 [XmlAttribute("name")]
7 public string DependencyName { get; set; }
7 public string DependencyName { get; set; }
8
8
9 [XmlAttribute("optional")]
9 [XmlAttribute("optional")]
10 public bool Optional { get; set; }
10 public bool Optional { get; set; }
11
11
12 internal override void Visit(InjectionValueBuilder builder) {
12 public override void Visit(InjectionValueBuilder builder) {
13 builder.Visit(this);
13 builder.Visit(this);
14 }
14 }
15 }
15 }
16 } No newline at end of file
16 }
@@ -1,8 +1,10
1 namespace Implab.ServiceHost.Unity {
1 namespace Implab.ServiceHost.Unity {
2 public interface IDependencyReference {
2 public interface IDependencyReference {
3
3
4 string TypeName { get; set; }
4 string TypeName { get; }
5
6 bool Optional { get; }
5
7
6 string DependencyName { get; set; }
8 string DependencyName { get; }
7 }
9 }
8 } No newline at end of file
10 }
@@ -1,8 +1,9
1 namespace Implab.ServiceHost.Unity {
1 namespace Implab.ServiceHost.Unity {
2 public interface ITextValue {
2 public interface ITextValue {
3
3 string TypeName { get; }
4 string TypeName { get; }
4
5
5 string Value { get; }
6 string Value { get; }
6
7
7 }
8 }
8 } No newline at end of file
9 }
@@ -1,12 +1,12
1 using System;
1 using System;
2 using System.Xml.Serialization;
2 using System.Xml.Serialization;
3
3
4 namespace Implab.ServiceHost.Unity {
4 namespace Implab.ServiceHost.Unity {
5 public abstract class InjectionParameterElement {
5 public abstract class InjectionParameterElement : IInjectionParameter {
6
6
7 [XmlAttribute("type")]
7 [XmlAttribute("type")]
8 public string TypeName { get; set; }
8 public string TypeName { get; set; }
9
9
10 internal abstract void Visit(InjectionValueBuilder builder);
10 public abstract void Visit(InjectionValueBuilder builder);
11 }
11 }
12 } No newline at end of file
12 }
@@ -1,37 +1,43
1 using System;
1 using System;
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 : AbstractRegistration, ISerializedValue {
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 string ISerializedValue.TypeName {
19 get {
19 get {
20 return string.IsNullOrEmpty(SerializedType) ? RegistrationType : SerializedType;
20 return string.IsNullOrEmpty(SerializedType) ? RegistrationType : SerializedType;
21 }
21 }
22 }
22 }
23
23
24 public string TypeName => throw new NotImplementedException();
25
24 public override void Visit(ContainerBuilder context) {
26 public override void Visit(ContainerBuilder context) {
25 context.Visit(this);
27 context.Visit(this);
26 }
28 }
27
29
28 public XmlReader GetReader() {
30 public XmlReader GetReader() {
29 if (!string.IsNullOrEmpty(Location))
31 if (!string.IsNullOrEmpty(Location))
30 return XmlReader.Create(Location);
32 return XmlReader.Create(Location);
31 if (Content != null && Content.Length > 0)
33 if (Content != null && Content.Length > 0)
32 return Content[0].CreateNavigator().ReadSubtree();
34 return Content[0].CreateNavigator().ReadSubtree();
33
35
34 throw new Exception("No content found, expected XML document");
36 throw new Exception("No content found, expected XML document");
35 }
37 }
38
39 public void Visit(InjectionValueBuilder builder) {
40 throw new NotImplementedException();
41 }
36 }
42 }
37 } No newline at end of file
43 }
@@ -1,28 +1,28
1 using System;
1 using System;
2 using System.Xml;
2 using System.Xml;
3 using System.Xml.Schema;
3 using System.Xml.Schema;
4 using System.Xml.Serialization;
4 using System.Xml.Serialization;
5
5
6 namespace Implab.ServiceHost.Unity
6 namespace Implab.ServiceHost.Unity
7 {
7 {
8 public class SerializedParameterElement : InjectionParameterElement, ISerializedValue {
8 public class SerializedParameterElement : InjectionParameterElement, ISerializedValue {
9 [XmlAttribute("href")]
9 [XmlAttribute("href")]
10 public string Location { get; set; }
10 public string Location { get; set; }
11
11
12 [XmlAnyElement]
12 [XmlAnyElement]
13 public XmlElement[] Content { get; set; }
13 public XmlElement[] Content { get; set; }
14
14
15 public XmlReader GetReader() {
15 public XmlReader GetReader() {
16 if (!string.IsNullOrEmpty(Location))
16 if (!string.IsNullOrEmpty(Location))
17 return XmlReader.Create(Location);
17 return XmlReader.Create(Location);
18 if (Content != null && Content.Length > 0)
18 if (Content != null && Content.Length > 0)
19 return Content[0].CreateNavigator().ReadSubtree();
19 return Content[0].CreateNavigator().ReadSubtree();
20
20
21 throw new Exception("No content found, expected XML document");
21 throw new Exception("No content found, expected XML document");
22 }
22 }
23
23
24 internal override void Visit(InjectionValueBuilder builder) {
24 public override void Visit(InjectionValueBuilder builder) {
25 builder.Visit(this);
25 builder.Visit(this);
26 }
26 }
27 }
27 }
28 } No newline at end of file
28 }
@@ -1,13 +1,13
1 using System.Xml.Serialization;
1 using System.Xml.Serialization;
2
2
3 namespace Implab.ServiceHost.Unity {
3 namespace Implab.ServiceHost.Unity {
4 public class ValueParameterElement : InjectionParameterElement, ITextValue {
4 public class ValueParameterElement : InjectionParameterElement, ITextValue {
5 [XmlText]
5 [XmlText]
6 [XmlAttribute("value")]
6 [XmlAttribute("value")]
7 public string Value { get; set; }
7 public string Value { get; set; }
8
8
9 internal override void Visit(InjectionValueBuilder builder) {
9 public override void Visit(InjectionValueBuilder builder) {
10 builder.Visit(this);
10 builder.Visit(this);
11 }
11 }
12 }
12 }
13 } No newline at end of file
13 }
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