Skip to content

Generic Request/Handler #778

Answered by crowz4k
crowz4k asked this question in Q&A
Aug 27, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

@01Raja Yes with AutoFac. AutoFac can resolve this in runtime.

// DI Register AutoFac modules
builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
{
    builder.RegisterModule(new ApplicationServicesModule());
});

And then adding in ApplicationServicesModule following:

    public class ApplicationServicesModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterGeneric(typeof(GetByIdHandler<,>)).AsImplementedInterfaces();
        }
    }

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@zachpainter77
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by crowz4k
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants