Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 6
0
 protected abstract void RegisterImplementationWithContainer <TInterface, TImplementation>(IocLifetime lifeTime) where TImplementation : class, TInterface where TInterface : class;
Exemplo n.º 7
0
 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();
 }