-
-
Notifications
You must be signed in to change notification settings - Fork 274
Description
I am looking to implement a TryAddTransient solution but for scanning multiple interfaces. Currently my code will either add duplicates or I have a workaround which replaces the existing ones. What I really want is for the code to identify that the interfaces AND the implementations already exist so do nothing.
I'm a BDD kind of dev so here's the scenario:
Given I want to implement a strategy pattern with many classes implementing the same interface
When I hit the Scan code more than once
Then it will not add duplicates or replace existing services in the container
Current behaviour:
The skip functionality will perform a TryAdd which only appears to check the service. So when Scanning it will only add one implementation of that service rather than all the strategies.
Work around:
Use .UsingRegistrationStrategy(RegistrationStrategy.Replace(ReplacementBehavior.ImplementationType)).
But this will remove and replace those implementations with isn't specifically what I need
The code I wish I had:
.UsingRegistrationStrategy(RegistrationStrategy.Skip(SkipBehavior.ImplementationType)).