Example #1
0
 /// <summary>
 /// Binds <see cref="TService"/> to <see cref="TImplementation"/> and configures Ninject factories in the form
 /// of <see cref="Func{TString, TService}"/> and <see cref="Func{TString, TImplementation}"/> to return the same
 /// instance every time the factory is called with the same <see cref="string"/>.
 /// </summary>
 /// <typeparam name="TService">The type of the service (or interface) to bind.</typeparam>
 /// <typeparam name="TImplementation">The type of the implementation of the service to bind to.</typeparam>
 /// <param name="kernel">The Ninject kernel on which to set up the binding.</param>
 public static void BindPerString <TService, TImplementation>(this IKernel kernel)
     where TImplementation : TService
 {
     kernel.BindPerKey <string, TService, TImplementation>();
 }
Example #2
0
 /// <summary>
 /// Configures Ninject factories in the form of <see cref="Func{TKey, TImplementation}"/> to return the same
 /// instance every time the factory is called with the same parameter of type <see cref="TKey"/>.
 /// </summary>
 /// <typeparam name="TKey">The type of the parameter passed to the factory.</typeparam>
 /// <typeparam name="TImplementation">The type of the implementation of the service to bind to.</typeparam>
 /// <param name="kernel">The Ninject kernel on which to set up the binding.</param>
 public static void BindPerKey <TKey, TImplementation>(this IKernel kernel)
 {
     kernel.BindPerKey <TKey, TImplementation, TImplementation>();
 }