Mercurial > pub > ImplabNet
comparison Implab.ServiceHost/Unity/RegisterElement.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 | 22629bf26121 |
children | 8714471e8d78 |
comparison
equal
deleted
inserted
replaced
276:b4e0f81c7425 | 277:963b17c275be |
---|---|
4 using Unity.Registration; | 4 using Unity.Registration; |
5 | 5 |
6 namespace Implab.ServiceHost.Unity { | 6 namespace Implab.ServiceHost.Unity { |
7 | 7 |
8 [XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)] | 8 [XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)] |
9 public class RegisterElement : AbstractRegistration { | 9 public class RegisterElement : TypeAbstractRegistration { |
10 | 10 |
11 /// <summary> | 11 /// <summary> |
12 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. | 12 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. |
13 /// </summary> | 13 /// </summary> |
14 [XmlAttribute("mapTo")] | 14 [XmlAttribute("mapTo")] |
16 | 16 |
17 | 17 |
18 [XmlElement("constructor", typeof(ConstructorInjectionElement))] | 18 [XmlElement("constructor", typeof(ConstructorInjectionElement))] |
19 [XmlElement("property", typeof(PropertyInjectionElement))] | 19 [XmlElement("property", typeof(PropertyInjectionElement))] |
20 [XmlElement("method", typeof(MethodInjectionElement))] | 20 [XmlElement("method", typeof(MethodInjectionElement))] |
21 public AbstractInjectionElement[] Injectors { get; set; } | 21 public AbstractMemberInjection[] Injectors { get; set; } |
22 | 22 |
23 public override void Visit(ContainerBuilder context) { | 23 public override Type GetImplementationType(Func<string, Type> resolver) { |
24 context.Visit(this); | 24 return string.IsNullOrEmpty(MapToType) ? null : resolver(MapToType); |
25 } | 25 } |
26 | |
27 public override void Visit(TypeRegistrationBuilder builder) { | |
28 if(Injectors != null) | |
29 foreach(var injector in Injectors) | |
30 injector.Visit(builder); | |
31 } | |
32 | |
33 | |
26 } | 34 } |
27 | 35 |
28 } | 36 } |