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 it possible to specify the registration order? #183

Open
blahDL opened this issue Oct 26, 2022 · 2 comments
Open

Question: Is it possible to specify the registration order? #183

blahDL opened this issue Oct 26, 2022 · 2 comments

Comments

@blahDL
Copy link

blahDL commented Oct 26, 2022

I am using Scrutor to register pipeline behaviours for MediatR which is working perfectly with the following code

builder.Services.Scan(scan => scan.FromAssemblyOf<Program>()
    .AddClasses(cls => cls.AssignableTo(typeof(IPipelineBehavior<,>)))
        .AsImplementedInterfaces()
        .WithScopedLifetime()
);

I have now introduced a pipeline behaviour that I want to be run before the others. Pipeline execution order is set by the order they are registered with the container so now I need to either specify the registration order somehow or register them all manually.

Is there a way that I can specify the registration order (by using something like an attribute on the classes) or do I have to stop using Scrutor for this and register them all manually?

@anreton
Copy link

anreton commented Sep 18, 2023

@blahDL, +1

@khellang, it would be very useful to describe exactly what the registration order is when calling a Scan. I couldn't find any information about this anywhere.

How does multiple implementation of interface is registered? E.g. Class1, Class2 and Class3 implements Interface1. How this can be registered with Scrutor? How can I control the registration order?

@khellang
Copy link
Owner

I'd love to hear what you'd expect the API to look like and how it would work? Would it order all implementations per service type or globally? Would it work with an IComparer<Type>?

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

3 participants