TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Geni Lou
NA
101
24.2k
Dependency Injection in WinForms
Feb 27 2021 3:06 AM
in Program.cs I add this code:
services.AddDbContext<InventoryDbContext>(context => context.UseSqlServer(constr));
services.AddScoped<IClassService, ClassService>();
services.AddScoped<ICategoryService, CategoryService>();
in MDIForm I add this code:
private
readonly
IClassService classService;
private
readonly
ICategoryService categoryService;
public
MdiForm(IClassificationService classificationService, ICategoryService categoryService){
this
.classService = classService;
this
.categoryService = categoryService;}
then to show a category from MDI I do this code. But in order to add the classService from CategoryForm to Classification, it should be a part of CategoryForm.
from MDI Form to show CategoryForm:
var categoryForm =
new
frmCategory(classService, categoryService);
categoryForm.ShowDialog();
from CategoryForm to show ClassForm:
var classForm =
new
frmClass(classService);
classForm .ShowDialog();
Reply
Answers (
3
)
I'm extracting XML from url in c# But facing this error Message=An XML
Typed dataset not working,