Пример #1
0
        public void Register(Type TClass, RegistrationScopeEnum registrationType)
        {
            var binder = Kernel.Bind(TClass).ToSelf();

            if (registrationType == RegistrationScopeEnum.Singleton)
            {
                binder.InSingletonScope();
            }
        }
Пример #2
0
        public void Register(Type TClass, Type @interface, RegistrationScopeEnum registrationType)
        {
            var binder = Kernel.Bind(@interface).To(TClass);

            if (registrationType == RegistrationScopeEnum.Singleton)
            {
                binder.InSingletonScope();
            }
        }
        private LifetimeManager GetLifetimeManager(RegistrationScopeEnum registrationType)
        {
            switch (registrationType)
            {
            case RegistrationScopeEnum.Default:
                return(null);

            case RegistrationScopeEnum.Singleton:
                return(new ContainerControlledLifetimeManager());
            }
            return(null);
        }
        private void RegisterAsType(IRegistrationBuilder <object, ConcreteReflectionActivatorData, SingleRegistrationStyle> registrationBuilder,
                                    RegistrationScopeEnum registrationType)
        {
            switch (registrationType)
            {
            case RegistrationScopeEnum.Default:
                registrationBuilder.InstancePerDependency();
                break;

            case RegistrationScopeEnum.Singleton:
                registrationBuilder.SingleInstance();
                break;
            }
        }
 public void Register(Type TClass, RegistrationScopeEnum registrationType)
 {
     Container.RegisterType(TClass, GetLifetimeManager(registrationType));
 }
 public void Register(Type TClass, RegistrationScopeEnum registrationType)
 {
     RegisterAsType(_containerBuilder.RegisterType(TClass).AsSelf(), registrationType);
 }
 public void Register(Type TClass, Type @interface, RegistrationScopeEnum registrationType = RegistrationScopeEnum.Default)
 {
     RegisterAsType(_containerBuilder.RegisterType(TClass).As(@interface), registrationType);
 }
Пример #8
0
 public RegisterThisServiceAttribute()
 {
     _registrationType = RegistrationScopeEnum.Default;
 }
Пример #9
0
 public RegisterThisServiceAttribute(RegistrationScopeEnum registrationType)
 {
     _registrationType = registrationType;
 }