Added constraint for RegisterType

This commit is contained in:
Holger Boerchers 2018-08-15 08:50:17 +02:00
parent 1d2fca6ddc
commit d7e6dcc3b2
2 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ namespace SmallInjectorDemo
useful2.TestTheServices(); useful2.TestTheServices();
Console.WriteLine(); Console.WriteLine();
useful3.TestTheServices(); useful3.TestTheServices();
Console.ReadLine(); //Console.ReadLine();
} }
} }
} }

View File

@ -17,7 +17,7 @@ namespace SmallInjectorDemo
/// <typeparam name="TInterface">Type of the interface of the service.</typeparam> /// <typeparam name="TInterface">Type of the interface of the service.</typeparam>
/// <param name="isSingleton">True if the service should be singleton. False otherwise.</param> /// <param name="isSingleton">True if the service should be singleton. False otherwise.</param>
/// <param name="instance">instance of the service</param> /// <param name="instance">instance of the service</param>
public void RegisterType<TService, TInterface>(bool isSingleton, TService instance = default(TService)) public void RegisterType<TService, TInterface>(bool isSingleton, TService instance = default(TService)) where TService : TInterface
{ {
_container.Add(typeof(TInterface), new RegisteredType(typeof(TService), isSingleton, null)); _container.Add(typeof(TInterface), new RegisteredType(typeof(TService), isSingleton, null));
} }