public IRegistrationContainer Register(Type abstractType, Type concreteType, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { _container.Register(abstractType, concreteType, registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace)); return(this); }
public IRegistrationContainer Register(Type abstractType, Type concreteType, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { _container.Register(abstractType, concreteType, registrationLifeTime.ToContainerLifeTime()); return(this); }
public IRegistrationContainer RegisterFactory <TAbstract>(Func <IResolutionContainer, TAbstract> factoryFunc, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) where TAbstract : class { _container.RegisterDelegate(_ => factoryFunc(DryIocResolverAdapter.Adapt(_container)), registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace)); return(this); }
public IRegistrationContainer Register(Type concreteType, RegistrationTarget target, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { var serviceTypeCondition = TargetResolver.Resolve(target); _container.RegisterMany(new[] { concreteType }, registrationLifeTime.ToContainerLifeTime(), serviceTypeCondition: serviceTypeCondition, serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace)); return(this); }
public IRegistrationContainer Register <TAbstract, TConcrete>( RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, Action <TAbstract> cleanupAction = null, string key = null, bool shouldReplace = false) where TAbstract : class where TConcrete : class, TAbstract { _container.Register <TAbstract, TConcrete>(registrationLifeTime.ToContainerLifeTime()); return(this); }
public IRegistrationContainer RegisterFactory <TAbstract>(Func <IResolutionContainer, TAbstract> factoryFunc, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) where TAbstract : class { SimpleInjectorIocResolverAdapter c = SimpleInjectorIocResolverAdapter.Adapt(_container); _container.Register <TAbstract>(() => factoryFunc(c), registrationLifeTime.ToContainerLifeTime()); return(this); }
public IRegistrationContainer Register(Type concreteType, RegistrationTarget target, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { var serviceTypeCondition = TargetResolver.Resolve(target); //_container.Register(concreteType); //_container.Register( concreteType.UnderlyingSystemType, () => concreteType, registrationLifeTime.ToContainerLifeTime()); _container.Register(concreteType.GetType(), () => concreteType, registrationLifeTime.ToContainerLifeTime()); return(this); }
public RegistrationInfo(RegistrationLifeTime lifeTime, string key = "") { if (!lifeTime.IsMemberOf <RegistrationLifeTime>()) { throw new ArgumentOutOfRangeException(nameof(lifeTime)); } LifeTime = lifeTime; HasKey = !string.IsNullOrWhiteSpace(key); Key = HasKey ? key : string.Empty; }
public IRegistrationContainer Register <TAbstract, TConcrete>( RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, Action <TAbstract> cleanupAction = null, string key = null, bool shouldReplace = false) where TAbstract : class where TConcrete : class, TAbstract { _container.Register <TAbstract, TConcrete>(registrationLifeTime.ToContainerLifeTime(), serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace)); if (cleanupAction != null) { _container.RegisterDisposer(cleanupAction); } return(this); }
public IRegistrationContainer RegisterDecorator(Type abstractType, Type decorator, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { var serviceKey = ResolveKey(key); if (string.IsNullOrEmpty(serviceKey)) { _container.Register(abstractType, decorator, registrationLifeTime.ToContainerLifeTime(), setup: Setup.Decorator, ifAlreadyRegistered: Map(shouldReplace)); } else { _container.Register(abstractType, decorator, registrationLifeTime.ToContainerLifeTime(), setup: Setup.DecoratorWith(r => string.Equals(key, r.ServiceKey as string, StringComparison.OrdinalIgnoreCase))); } return(this); }
public static Lifestyle ToContainerLifeTime(this RegistrationLifeTime lifeTime) { switch (lifeTime) { case RegistrationLifeTime.Singleton: return(Lifestyle.Singleton); case RegistrationLifeTime.Transient: return(Lifestyle.Transient); case RegistrationLifeTime.ScopedOrSingleton: return(Lifestyle.Scoped); default: return(Lifestyle.Scoped); } }
public IRegistrationContainer RegisterDecorator(Type abstractType, Type decorator, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { throw new NotImplementedException(); }
public IRegistrationContainer RegisterDecorator <TAbstract, TConcrete>(RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) where TAbstract : class where TConcrete : class, TAbstract { throw new NotImplementedException(); }
public IRegistrationContainer Register <TConcrete>(RegistrationTarget target, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { return(Register(typeof(TConcrete), target, registrationLifeTime, key, shouldReplace)); }
public IoCRegistrationAttribute(RegistrationLifeTime lifeTime, string key = "") { Information = new RegistrationInfo(lifeTime, key); }
public bool Matches(RegistrationLifeTime lifeTime) { return(lifeTime == LifeTime); }