Skip to content

Add Container.Collection.RegisterConditional #1012

Description

@dotnetjunkie

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions