xamarin/urho

Dependency injection for Application

Opened this issue · 2 comments

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 commented

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.