c# - StructureMap - Get constructor dependencies via name -


How can I get constructor dependencies based on my name when the class itself does not require concrete implementation by name is. / P>

  public class PriceValidator: IPriceValidator {Private Reddone IEnumerable & lt; IPriceValidationRule & gt; _priceValidationRules; Public Prize Provider (IIMMERABLE & LT; IPRCI Validity Rules & gt; Value Validation Rules) {_priceValidationRules = Value Validation Rules; } Public Bull ISPCIC Adial (Decimal Value) {Return _ Prose Validity Rule.All (Valuidator => Price Viaductor. ISPras Valid (value)); }}   

Call:

  _priceValidator = ObjectFactory.GetInstance & lt; IPriceValidator & gt; ();   

So I want a solid implementation of IPriceValidator, but specific (by name) validation rule.

Edit:

My rules:

How can I use the same rules with different names? So when I say, give me all the examples named "X", do I want to get the MaxPrice validity rule?

I would recommend making my own factory, this factory will be able to create your own specific example of class Will be. Then by applying this factory as dependence, where you want to use your specific example.

Comments