ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Question: How to enumerate all keys of the interface registration? #200

Closed mcdis closed 5 years ago

mcdis commented 5 years ago

Hi! Need to enumeration all keys of the interface available from the scope Best regards

ipjohnson commented 5 years ago

Hi @mcdis

the container has the property StrategyCollectionContainer

// return all strategies for the container
container.StrategyCollectionContainer.GetAllStrategies();

// get keyed strategies by type
var collection = container.StrategyCollectionContainer.GetActivationStrategyCollection(typeof(ISomeInterface));

if(collection != null)
{
   foreach(KeyValuePair<object,ICompiledExportStrategy> kvp in collection.GetKeyedStrategies)
   {
      // 
   }
}
ipjohnson commented 5 years ago

@mcdis I'm going to close this out