Mercurial > pub > ImplabNet
annotate Implab.ServiceHost/Unity/RegisterElement.cs @ 278:6691aff01de1 v3
Implab: added XmlDefaultSeializer (SerializersPool is now obsolete)
Implab.ServiceHost: rewritten TypeReference (added support for nested types), stable API
| author | cin |
|---|---|
| date | Thu, 03 May 2018 09:59:44 +0300 |
| parents | 963b17c275be |
| children | 8714471e8d78 |
| rev | line source |
|---|---|
| 269 | 1 using System; |
| 2 using System.Xml.Serialization; | |
| 3 using Unity.Lifetime; | |
| 4 using Unity.Registration; | |
| 5 | |
| 6 namespace Implab.ServiceHost.Unity { | |
| 7 | |
| 8 [XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)] | |
| 277 | 9 public class RegisterElement : TypeAbstractRegistration { |
| 269 | 10 |
| 11 /// <summary> | |
| 271 | 12 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. |
| 269 | 13 /// </summary> |
|
273
79110a16cab7
Working on Unity xml configuration: Refactoring in progress
cin
parents:
272
diff
changeset
|
14 [XmlAttribute("mapTo")] |
|
79110a16cab7
Working on Unity xml configuration: Refactoring in progress
cin
parents:
272
diff
changeset
|
15 public string MapToType { get; set; } |
| 269 | 16 |
| 17 | |
| 270 | 18 [XmlElement("constructor", typeof(ConstructorInjectionElement))] |
| 19 [XmlElement("property", typeof(PropertyInjectionElement))] | |
| 20 [XmlElement("method", typeof(MethodInjectionElement))] | |
| 277 | 21 public AbstractMemberInjection[] Injectors { get; set; } |
| 22 | |
| 23 public override Type GetImplementationType(Func<string, Type> resolver) { | |
| 24 return string.IsNullOrEmpty(MapToType) ? null : resolver(MapToType); | |
| 25 } | |
| 272 | 26 |
| 277 | 27 public override void Visit(TypeRegistrationBuilder builder) { |
| 28 if(Injectors != null) | |
| 29 foreach(var injector in Injectors) | |
| 30 injector.Visit(builder); | |
| 272 | 31 } |
| 277 | 32 |
| 33 | |
| 269 | 34 } |
| 35 | |
| 36 } |
