Код: Выделить всё
public interface IOurService {
void DoStuff();
}
public class OurService: IOurService {
public void DoStuff() {
//do things here
}
}
Код: Выделить всё
public static void AddOurServices(this IServiceCollection services) {
services.AddSingleton();
}
Однако проблема в том, что что они могут переопределить IOurService с помощью своей собственной реализации через DI.
Код: Выделить всё
services.AddOurSerivces();
services.AddSingleton();
Подробнее здесь: https://stackoverflow.com/questions/793 ... -public-in
Мобильная версия