annotate Implab.ServiceHost/Unity/ValueParameterElement.cs @ 281:e0916ddc9950 v3 tip

code cleanup and refactoring
author cin
date Fri, 01 Jun 2018 21:35:24 +0300
parents 6691aff01de1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
277
963b17c275be Refactoring
cin
parents: 275
diff changeset
1 using System.ComponentModel;
272
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 270
diff changeset
2 using System.Xml.Serialization;
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 270
diff changeset
3
274
22629bf26121 Unity xml configuration, alpha2
cin
parents: 273
diff changeset
4 namespace Implab.ServiceHost.Unity {
281
e0916ddc9950 code cleanup and refactoring
cin
parents: 278
diff changeset
5 public class ValueParameterElement : AbstractInjectionParameter {
273
79110a16cab7 Working on Unity xml configuration: Refactoring in progress
cin
parents: 272
diff changeset
6 [XmlAttribute("value")]
272
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 270
diff changeset
7 public string Value { get; set; }
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 270
diff changeset
8
277
963b17c275be Refactoring
cin
parents: 275
diff changeset
9 [XmlText]
963b17c275be Refactoring
cin
parents: 275
diff changeset
10 public string Text { get; set; }
963b17c275be Refactoring
cin
parents: 275
diff changeset
11
963b17c275be Refactoring
cin
parents: 275
diff changeset
12 string GetTextValue() {
963b17c275be Refactoring
cin
parents: 275
diff changeset
13 return string.IsNullOrEmpty(Value) ? Text : Value;
963b17c275be Refactoring
cin
parents: 275
diff changeset
14 }
963b17c275be Refactoring
cin
parents: 275
diff changeset
15
278
6691aff01de1 Implab: added XmlDefaultSeializer (SerializersPool is now obsolete)
cin
parents: 277
diff changeset
16 public override void Visit(InjectionParameterBuilder builder) {
277
963b17c275be Refactoring
cin
parents: 275
diff changeset
17 var type = builder.ResolveInjectedValueType(TypeName);
963b17c275be Refactoring
cin
parents: 275
diff changeset
18 builder.SetValue(type, TypeDescriptor.GetConverter(type).ConvertFromString(GetTextValue()));
272
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 270
diff changeset
19 }
270
ade80d94dfb5 Working on Unity container xml configuration
cin
parents:
diff changeset
20 }
ade80d94dfb5 Working on Unity container xml configuration
cin
parents:
diff changeset
21 }