view Implab.ServiceHost/Unity/RegistrationBuilder.cs @ 278:6691aff01de1 v3

Implab: added XmlDefaultSeializer (SerializersPool is now obsolete) Implab.ServiceHost: rewritten TypeReference (added support for nested types), stable API
author cin
date Thu, 03 May 2018 09:59:44 +0300
parents 963b17c275be
children f07be402ab02
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
using Implab.Xml;
using Unity.Injection;
using Unity.Lifetime;
using Unity.Registration;

namespace Implab.ServiceHost.Unity {
    /// <summary>
    /// Базовый класс для формирования записей в контейнере, созволяет указать время жизни для записи
    /// </summary>
    public abstract class RegistrationBuilder {
        public Type RegistrationType {
            get;
            private set;
        }

        internal LifetimeManager Lifetime { get; set; }

        protected RegistrationBuilder(Type registrationType) {
            RegistrationType = registrationType;
        }

        internal void Visit(SingletonLifetimeElement simgletonLifetime) {
            Lifetime = new SingletonLifetimeManager();
        }

        internal void Visit(ContainerLifetimeElement containerLifetime) {
            Lifetime = new ContainerControlledLifetimeManager();
        }

        internal void Visit(HierarchicalLifetimeElement hierarchicalLifetime) {
            Lifetime = new HierarchicalLifetimeManager();
        }

        internal void Visist(ContextLifetimeElement contextLifetime) {
            Lifetime = new PerResolveLifetimeManager();
        }
    }
}