locked
Unity DI Generic Types.. RRS feed

  • Question

  • Hi,

    It doesn't matter how much I read articles on this, I still can't get my head around the best way of doing this.

    I'm using a Unity container to inject dependencies in to my viewmodels.

    It's all working fine as it is but I'm still manually newing up a class that does some incremental loading of items over http.

    public class InvokeApiAsyncHelper<T> : IInvokeApiAsyncHelper<T> where T : class, new()

    I don't have access to the code for this and I need to pass a string in the constructor.

    My problem is that in one viewmodel I might need say five instances of IInvokeApiAsyncHelper<T> all with a different type T and requiring different strings passing to the constructor.

    So I'm looking to have the container resolve this class but I'm wondering the best way of doing it.

    Do I need to register every combination I might need in the container, or am I missing a trick here?

    Thanks

    Russ

    • Moved by Martin Zhema Tuesday, September 27, 2016 3:01 AM off-topic
    Monday, September 26, 2016 9:46 PM

All replies

  • Hi Russty,

    The UWP forum does not support Unity, you can go to Unity forum to post your question.

    Thanks.

    http://forum.unity3d.com/


    Best Regards!
    Martin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 27, 2016 2:59 AM