RegisterElement.cs
38 lines
| 1.2 KiB
| text/x-csharp
|
CSharpLexer
cin
|
r269 | using System; | |
cin
|
r279 | using System.Collections.Generic; | |
cin
|
r269 | using System.Xml.Serialization; | |
using Unity.Lifetime; | |||
using Unity.Registration; | |||
namespace Implab.ServiceHost.Unity { | |||
[XmlRoot("register", Namespace = Schema.ContainerConfigurationNamespace)] | |||
cin
|
r279 | public class RegisterElement : AbstractRegistration, ITypeRegistration { | |
cin
|
r269 | ||
/// <summary> | |||
cin
|
r271 | /// An optional type which is registered as a service in the container, must be assignable to <see cref="ProvidesType">. | |
cin
|
r269 | /// </summary> | |
cin
|
r273 | [XmlAttribute("mapTo")] | |
public string MapToType { get; set; } | |||
cin
|
r269 | ||
cin
|
r270 | [XmlElement("constructor", typeof(ConstructorInjectionElement))] | |
[XmlElement("property", typeof(PropertyInjectionElement))] | |||
[XmlElement("method", typeof(MethodInjectionElement))] | |||
cin
|
r277 | public AbstractMemberInjection[] Injectors { get; set; } | |
cin
|
r279 | IEnumerable<ITypeMemberInjection> ITypeRegistration.MemberInjections { | |
get { | |||
return Injectors; | |||
} | |||
cin
|
r277 | } | |
cin
|
r272 | ||
cin
|
r279 | public Type GetImplementationType(ContainerBuilder builder) { | |
return builder.ResolveType(MapToType); | |||
cin
|
r272 | } | |
cin
|
r277 | ||
cin
|
r279 | public override void Visit(ContainerBuilder builder) { | |
builder.Visit(this); | |||
} | |||
cin
|
r269 | } | |
} |