public void RegisterType <T>(IocLifetime lifeTime = IocLifetime.Transient) where T : class { try { RegisterTypeWithContainer <T>(lifeTime); } catch (Exception e) { throw new IocContainerException($"Failed to register {typeof(T).Name} with the Ioc container", e); } }
public void RegisterImplementation <TInterface, TImplementation>(IocLifetime lifeTime = IocLifetime.Transient) where TImplementation : class, TInterface where TInterface : class { try { RegisterImplementationWithContainer <TInterface, TImplementation>(lifeTime); } catch (Exception e) { throw new IocContainerException($"Failed to register {typeof(TImplementation).Name} as implementation of {typeof(TInterface).Name} with the Ioc container", e); } }
protected override void RegisterTypeWithContainer <T>(IocLifetime lifeTime) { if (lifeTime == IocLifetime.Transient) { _dryIocContainer.Register <T>(Reuse.Transient, Made.Default, Setup.With(allowDisposableTransient: true)); } else { _dryIocContainer.Register <T>(Reuse.Singleton); } }
protected override void RegisterTypeWithContainer <T>(IocLifetime lifeTime) { if (lifeTime == IocLifetime.Singleton) { _serviceCollection.AddSingleton <T>(); _serviceProviderInstance = _serviceCollection.BuildServiceProvider(); } else { _serviceCollection.AddTransient <T>(); _serviceProviderInstance = _serviceCollection.BuildServiceProvider(); } }
public void Register(Type from, Type to, IocLifetime lifetime) { if (lifetime == IocLifetime.PerRequest) { _ioCManagerThunk().AddPerRequest(from, to); } else if (lifetime == IocLifetime.SingleInstance) { _ioCManagerThunk().AddSingleInstance(from, to); } else { _ioCManagerThunk().AddPerDependency(from, to); } }
protected abstract void RegisterImplementationWithContainer <TInterface, TImplementation>(IocLifetime lifeTime) where TImplementation : class, TInterface where TInterface : class;
protected abstract void RegisterTypeWithContainer <T>(IocLifetime lifeTime) where T : class;
protected override void RegisterImplementationWithContainer <TInterface, TImplementation>(IocLifetime lifeTime) { throw new NotImplementedException(); }
protected override void RegisterTypeWithContainer <T>(IocLifetime lifeTime) { throw new NotImplementedException(); }