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

Add Container.Collection.RegisterConditional #1012

Open
dotnetjunkie opened this issue Dec 16, 2024 · 0 comments
Open

Add Container.Collection.RegisterConditional #1012

dotnetjunkie opened this issue Dec 16, 2024 · 0 comments

Comments

@dotnetjunkie
Copy link
Collaborator

dotnetjunkie commented Dec 16, 2024

Allow collections to be registered conditional, similar to what Container.RegisterConditional does for non-collection registrations.

e.g.:

container.Collection.RegisterConditional(
    serviceType: typeof(ILogger),
    serviceTypes: new[] { typeof(SqlLogger), typeof(FileLogger) },
    c => c.Consumer.Target.Name.StartsWith("realLoggers"));

container.Collection.RegisterConditional(
    serviceType: typeof(ILogger),
    serviceTypes: new[] { typeof(ConsoleLogger), typeof(NullLogger) },
    c => !c.Handled);

The difficulty in this feature is the following:

  • It should work for both ambient and flowing scope scenarios
  • It should work for all supported collection types

Related to #1009 and #1010.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant