Added dependency injection
This commit is contained in:
parent
2293c4f9e1
commit
39a9baf5c6
13 changed files with 59 additions and 581 deletions
34
imagecatalog/Program.cs
Normal file
34
imagecatalog/Program.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using ImageCatalog;
|
||||
using ImageCatalog_2.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ImageCatalog_2
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static IServiceProvider ServiceProvider { get; private set; }
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
var serviceCollection = new ServiceCollection();
|
||||
ConfigureServices(serviceCollection);
|
||||
|
||||
ServiceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
Application.Run(ServiceProvider.GetRequiredService<MainForm>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
// Register your services here
|
||||
services.AddTransient<ITestService, TestService>();
|
||||
|
||||
// Register your forms
|
||||
services.AddTransient<MainForm>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue