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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
1 using System;
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
2 using System.Collections.Generic;
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
3 using System.Xml.Serialization;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
4 using Unity.Lifetime;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
5 using Unity.Registration;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
6
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
7 namespace Implab.ServiceHost.Unity {
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
8
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
9 [XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)]
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
10 public class RegisterElement : AbstractRegistration, ITypeRegistration {
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
11
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
12 /// <summary>
271
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
13 /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">.
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
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
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
17
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
18
270
ade80d94dfb5 Working on Unity container xml configuration
cin
parents: 269
diff changeset
19 [XmlElement("constructor", typeof(ConstructorInjectionElement))]
ade80d94dfb5 Working on Unity container xml configuration
cin
parents: 269
diff changeset
20 [XmlElement("property", typeof(PropertyInjectionElement))]
ade80d94dfb5 Working on Unity container xml configuration
cin
parents: 269
diff changeset
21 [XmlElement("method", typeof(MethodInjectionElement))]
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
22 public AbstractMemberInjection[] Injectors { get; set; }
963b17c275be Refactoring
cin
parents: 274
diff changeset
23
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
24 IEnumerable<ITypeMemberInjection> ITypeRegistration.MemberInjections {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
25 get {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
26 return Injectors;
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
27 }
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
28 }
272
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 271
diff changeset
29
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
30 public Type GetImplementationType(ContainerBuilder builder) {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
31 return builder.ResolveType(MapToType);
272
9d1cca834b05 preview version of Unity xml configuration
cin
parents: 271
diff changeset
32 }
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
33
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
34 public override void Visit(ContainerBuilder builder) {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
35 builder.Visit(this);
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
36 }
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
37 }
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
38
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
39 }