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

[question] Is generic installers possible? #288

Open
wes-kay opened this issue Apr 8, 2024 · 0 comments
Open

[question] Is generic installers possible? #288

wes-kay opened this issue Apr 8, 2024 · 0 comments

Comments

@wes-kay
Copy link

wes-kay commented Apr 8, 2024

I would have asked in the discord, but the invite link is expired.

I would just like to know if it's possible to handle generics for installers (This compiles but I can't attach as a component)?

public class RequestInstaller<TRequest, TResponse> : MonoInstaller
{
    public override void InstallBindings()
    {
        Container.Bind<IRequestSystem<TRequest, TResponse>>().To<RequestSystem<TRequest, TResponse>>().AsSingle();
    }
}

https://github.com/modesttree/Zenject?tab=readme-ov-file#runtime-parameters-for-installers covers params but not generics, I'm looking to make a generic HTTP request / response class.

public interface IRequestSystem<TRequest, TResponse>
{
    Task<TResponse> RequestAsync(Endpoints endpoint, TRequest requestData);
}

public class RequestSystem<TRequest, TResponse> : IRequestSystem<TRequest, TResponse>
...
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