ValueParameterElement.cs
20 lines
| 670 B
| text/x-csharp
|
CSharpLexer
cin
|
r277 | using System.ComponentModel; | |
cin
|
r272 | using System.Xml.Serialization; | |
cin
|
r274 | namespace Implab.ServiceHost.Unity { | |
cin
|
r277 | public class ValueParameterElement : InjectionParameterElement { | |
cin
|
r273 | [XmlAttribute("value")] | |
cin
|
r272 | public string Value { get; set; } | |
cin
|
r277 | [XmlText] | |
public string Text { get; set; } | |||
string GetTextValue() { | |||
return string.IsNullOrEmpty(Value) ? Text : Value; | |||
} | |||
cin
|
r278 | public override void Visit(InjectionParameterBuilder builder) { | |
cin
|
r277 | var type = builder.ResolveInjectedValueType(TypeName); | |
builder.SetValue(type, TypeDescriptor.GetConverter(type).ConvertFromString(GetTextValue())); | |||
cin
|
r272 | } | |
cin
|
r270 | } | |
} |