annotate Implab.ServiceHost/Unity/AbstractRegistration.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;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
2 using System.Xml.Serialization;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
3 using Unity.Lifetime;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
4 using Unity.Registration;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
5
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
6 namespace Implab.ServiceHost.Unity
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
7 {
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
8 /// <summary>
963b17c275be Refactoring
cin
parents: 274
diff changeset
9 /// Базовая информаци о регистрации в контейнере: тип, имя и время жизни
963b17c275be Refactoring
cin
parents: 274
diff changeset
10 /// </summary>
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
11 public abstract class AbstractRegistration : AbstractContainerItem, IRegistration {
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
12
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
13 /// <summary>
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
14 /// An optional name for a registration in the container
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
15 /// </summary>
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
16 [XmlAttribute("name")]
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
17 public string Name {
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
18 get; set;
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
19 }
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
20
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
21 [XmlElement("signleton", typeof(SingletonLifetimeElement))]
271
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
22 [XmlElement("context", typeof(ContextLifetimeElement))]
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
23 [XmlElement("container", typeof(ContainerLifetimeElement))]
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
24 [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))]
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
25 public LifetimeElement Lifetime {get; set;}
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
26
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
27 /// <summary>
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
28 /// A type specification for the service registration,
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
29 /// </summary>
273
79110a16cab7 Working on Unity xml configuration: Refactoring in progress
cin
parents: 272
diff changeset
30 [XmlAttribute("type")]
79110a16cab7 Working on Unity xml configuration: Refactoring in progress
cin
parents: 272
diff changeset
31 public string RegistrationType { get; set; }
271
d4d437ec4483 Working on Unity xml configuration
cin
parents: 270
diff changeset
32
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
33 public virtual LifetimeManager GetLifetime(ContainerBuilder builder) {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
34 return Lifetime?.GetLifetime(builder);
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
35 }
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
36
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
37 public virtual Type GetRegistrationType(Func<string,Type> resolver) {
963b17c275be Refactoring
cin
parents: 274
diff changeset
38 return resolver(RegistrationType);
963b17c275be Refactoring
cin
parents: 274
diff changeset
39 }
963b17c275be Refactoring
cin
parents: 274
diff changeset
40
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
41 public virtual Type GetRegistrationType(ContainerBuilder builder) {
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
42 return builder.ResolveType(RegistrationType);
277
963b17c275be Refactoring
cin
parents: 274
diff changeset
43 }
963b17c275be Refactoring
cin
parents: 274
diff changeset
44
279
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
45
8714471e8d78 Container configuration cleanup, RC2
cin
parents: 277
diff changeset
46
269
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
47 }
ff581cff7003 Working on Unity container xml configuration
cin
parents:
diff changeset
48 }