static void Main(string[] args) { ServiceCollection services = new ServiceCollection(); services.AddTransient <IMyInterface1, MyClass1>(); services.AddTransient <IMyInterface2, MyClass2>(); services.AddTransient <IMyInterface3, MyClass3>(); services.AddTransient <IYourInterface, YourClass>(); ServiceProvider serviceProvider = services.BuildServiceProvider(); IYourInterface yourInterface = serviceProvider.GetService <IYourInterface>(); Console.WriteLine("Press any key for continuing..."); Console.ReadKey(); }
public YourController(IYourInterface client) { this._client = client; }