Код: Выделить всё
// assembly Foo
namespace Microsoft.Extensions.DependencyInjection
{
public static class IServiceCollectionExtensions
{
/// This is some info
public static IServiceCollection AddFoo(this IServiceCollection services)
{
// register some types in the DI container
return services;
}
}
}
// assembly Foo.Bar, which has a dependency on Foo
namespace Microsoft.Extensions.DependencyInjection
{
public static class IServiceCollectionExtensions
{
///
/// You don't need to call -- we'll do it for you
///
public static IServiceCollection AddFooBar(this IServiceCollection services)
{
services.AddFoo();
// register some other types in the DI container
return services;
}
}
}
Обратите внимание, что это надуманный пример. Я прекрасно понимаю, что в большинстве случаев одни и те же службы можно зарегистрировать несколько раз.
Как мне это сделать? Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/718 ... me-name-in
Мобильная версия