theilgaz / winforms-dependency-injection

a quick demonstration for using dependency injection in .net framework winforms application with mvp pattern.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinForms Dependency Injection Sample

A quick demonstration for using Dependency Injection in .NET Framework 4.7 WinForms Application with MVP Pattern.

Dependencies

Package Name Version
Microsoft.Extensions.DependencyInjection 5.0.1

Screenshots

Program.cs

You should register your services in ConfigureServices() method. The Service Provider property should be in Program.cs too. Method named GetService is just added for handling your service object easier.

Output


Presenter Layer

As I mentioned before, we are going to use GetService method from Program.cs to call our service objects here.

Output


View Layer

Now we are calling method from presenter like we do.

Output


Sample Service

Output


Output

In this sample, executing UI method from UserView which calls from UserPresenter that references IUserService which is the origin reference of method implemented in UserService.

Output

About

a quick demonstration for using dependency injection in .net framework winforms application with mvp pattern.


Languages

Language:C# 100.0%