Skip to content

Dependency Injection #1

@CPKreu

Description

@CPKreu

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions