Skip to content

[question] Is generic installers possible? #288

Description

@wes-kay

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>
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions