示例#1
0
 /// <summary>
 /// Adds a service implementation, raising an exception if any error occurs.
 /// </summary>
 /// <typeparam name="TService">Type of the service to be implemented.</typeparam>
 /// <param name="factory">Factory implementation for the service.</param>
 /// <exception cref="InvalidOperationException">If the implementation cannot be registered.</exception>
 public static void Add <TService>(this IServiceCollectionExtender services, Func <IServiceProvider, TService> factory)
 => services.Add(typeof(TService), ExposedImplementation.FromFactory(factory));
示例#2
0
 public void Setup(IServiceCollectionExtender services)
 {
     services.Add <IHelpPrinter, FancyHelpPrinter>();
     services.Add <ICommand, ConfCommand>();
 }
示例#3
0
 /// <summary>
 /// Adds a service implementation, raising an exception if any error occurs.
 /// </summary>
 /// <typeparam name="TService">Type of the service to be implemented.</typeparam>
 /// <typeparam name="TImplementation">Implementation type to register.</typeparam>
 /// <exception cref="InvalidOperationException">If the implementation cannot be registered.</exception>
 public static void Add <TService, TImplementation>(this IServiceCollectionExtender services) where TImplementation : class, TService
 => services.Add(typeof(TService), ExposedImplementation.FromType <TImplementation>());