using System; using System.Xml.Serialization; using Unity.Lifetime; namespace Implab.ServiceHost.Unity { /// /// Базовая информаци о регистрации в контейнере: тип, имя и время жизни /// public abstract class AbstractRegistration : AbstractContainerItem, IRegistration { /// /// An optional name for a registration in the container /// [XmlAttribute("name")] public string Name { get; set; } [XmlElement("singleton", typeof(SingletonLifetimeElement))] [XmlElement("context", typeof(ContextLifetimeElement))] [XmlElement("container", typeof(ContainerLifetimeElement))] [XmlElement("hierarchy", typeof(HierarchicalLifetimeElement))] public LifetimeElement Lifetime {get; set;} /// /// A type specification for the service registration, /// [XmlAttribute("type")] public string RegistrationType { get; set; } public virtual LifetimeManager GetLifetime(ContainerBuilder builder) { return Lifetime?.GetLifetime(builder); } public virtual Type GetRegistrationType(Func resolver) { return resolver(RegistrationType); } public virtual Type GetRegistrationType(ContainerBuilder builder) { return builder.ResolveType(RegistrationType); } } }