Mercurial > pub > ImplabNet
comparison Implab.ServiceHost/Unity/ValueParameterElement.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 | 6691aff01de1 |
comparison
equal
deleted
inserted
replaced
| 276:b4e0f81c7425 | 277:963b17c275be |
|---|---|
| 1 using System.ComponentModel; | |
| 1 using System.Xml.Serialization; | 2 using System.Xml.Serialization; |
| 2 | 3 |
| 3 namespace Implab.ServiceHost.Unity { | 4 namespace Implab.ServiceHost.Unity { |
| 4 public class ValueParameterElement : InjectionParameterElement, ITextValue { | 5 public class ValueParameterElement : InjectionParameterElement { |
| 5 [XmlText] | |
| 6 [XmlAttribute("value")] | 6 [XmlAttribute("value")] |
| 7 public string Value { get; set; } | 7 public string Value { get; set; } |
| 8 | 8 |
| 9 [XmlText] | |
| 10 public string Text { get; set; } | |
| 11 | |
| 12 string GetTextValue() { | |
| 13 return string.IsNullOrEmpty(Value) ? Text : Value; | |
| 14 } | |
| 15 | |
| 9 public override void Visit(InjectionValueBuilder builder) { | 16 public override void Visit(InjectionValueBuilder builder) { |
| 10 builder.Visit(this); | 17 var type = builder.ResolveInjectedValueType(TypeName); |
| 18 builder.SetValue(type, TypeDescriptor.GetConverter(type).ConvertFromString(GetTextValue())); | |
| 11 } | 19 } |
| 12 } | 20 } |
| 13 } | 21 } |
