Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injection #1

Open
CPKreu opened this issue Aug 30, 2024 · 0 comments
Open

Dependency Injection #1

CPKreu opened this issue Aug 30, 2024 · 0 comments

Comments

@CPKreu
Copy link
Member

CPKreu commented Aug 30, 2024

Having dependency injection available would be great!

I do love the ASP.NET application builder pattern and it might fit in here too
For the example it would probably look something like this

var builder = DrawieApplication.CreateBuilder(); // This would, alongside creating a builder with a service collection, add a DrawingEngine service

builder.Services.AddGlfwWindowing();
builder.Services.AddVulkanRenderApi();
builder.Services.AddSkiaBackend();
builder.Services.AddWindow<MainWindow>();
SkiaDrawingBackend drawingBackend = new SkiaDrawingBackend();
VulkanRenderApi renderApi = new VulkanRenderApi();
GlfwWindowingPlatform windowingPlatform = new GlfwWindowingPlatform(renderApi);

var app = builder.Build();

// Do some more initialization related stuff or CMD argument logic

app.Run<MainWindow>();

Dependency injection can be still be useful even if you don't want to use the application builder pattern

Note that the classless Program.cs file pattern is only available for Desktop and Web targets (so no android, not sure about ios)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant