Mercurial > pub > ImplabNet
annotate Implab.ServiceHost/Unity/RegisterElement.cs @ 281:e0916ddc9950 v3 tip
code cleanup and refactoring
| author | cin |
|---|---|
| date | Fri, 01 Jun 2018 21:35:24 +0300 |
| parents | 8714471e8d78 |
| children |
| rev | line source |
|---|---|
| 269 | 1 using System; |
| 279 | 2 using System.Collections.Generic; |
| 269 | 3 using System.Xml.Serialization; |
| 4 using Unity.Lifetime; | |
| 5 using Unity.Registration; | |
| 6 | |
| 7 namespace Implab.ServiceHost.Unity { | |
| 8 | |
| 9 [XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)] | |
| 279 | 10 public class RegisterElement : AbstractRegistration, ITypeRegistration { |
| 269 | 11 |
| 12 /// <summary> | |
| 271 | 13 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. |
| 269 | 14 /// </summary> |
|
273
79110a16cab7
Working on Unity xml configuration: Refactoring in progress
cin
parents:
272
diff
changeset
|
15 [XmlAttribute("mapTo")] |
|
79110a16cab7
Working on Unity xml configuration: Refactoring in progress
cin
parents:
272
diff
changeset
|
16 public string MapToType { get; set; } |
| 269 | 17 |
| 18 | |
| 270 | 19 [XmlElement("constructor", typeof(ConstructorInjectionElement))] |
| 20 [XmlElement("property", typeof(PropertyInjectionElement))] | |
| 21 [XmlElement("method", typeof(MethodInjectionElement))] | |
| 277 | 22 public AbstractMemberInjection[] Injectors { get; set; } |
| 23 | |
| 279 | 24 IEnumerable<ITypeMemberInjection> ITypeRegistration.MemberInjections { |
| 25 get { | |
| 26 return Injectors; | |
| 27 } | |
| 277 | 28 } |
| 272 | 29 |
| 279 | 30 public Type GetImplementationType(ContainerBuilder builder) { |
| 31 return builder.ResolveType(MapToType); | |
| 272 | 32 } |
| 277 | 33 |
| 279 | 34 public override void Visit(ContainerBuilder builder) { |
| 35 builder.Visit(this); | |
| 36 } | |
| 269 | 37 } |
| 38 | |
| 39 } |
