Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Dependency injection for Application #401

Open
Haukinger opened this issue Jun 14, 2020 · 2 comments
Open

Dependency injection for Application #401

Haukinger opened this issue Jun 14, 2020 · 2 comments

Comments

@Haukinger
Copy link

The Urho.Extensions.WinForms.UrhoSurface uses Activator.CreateInstance to produce the application instance in Show. This means that one cannot inject any dependencies and has to resort to some static service locator.

It would be cool if there was a Show overload that took a Func<ApplicationOptions, Application> to produce the application instance which could be made to redirect to the dependency injection container in use.

@hwd71
Copy link

hwd71 commented Jun 15, 2020 via email

@Haukinger
Copy link
Author

Can you pass in a subclass of ApplicationOptions to the ctor?

This works, actually, but the code looks rather ugly.

I've made the derived options type that gets all the dependencies a nested class in my urho application, and the attached property that calls UrhoSurface.Show uses the common service locator to create the options instance.

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

No branches or pull requests

2 participants