Skip to content

Instantly share code, notes, and snippets.

@StacyGay
Created July 13, 2014 21:05
Show Gist options
  • Save StacyGay/61f4bd0a7fe236d3fffe to your computer and use it in GitHub Desktop.
Save StacyGay/61f4bd0a7fe236d3fffe to your computer and use it in GitHub Desktop.
ExtensionLoader example
public class ExtensionLoader
{
private readonly IUnityContainer _container;
private readonly IClientConfigRepo _configRepo;
public ExtensionLoader(IUnityContainer container, IClientConfigRepo configRepo)
{
_configRepo = configRepo;
_container = container;
}
public void LoadExtensions(string clientName)
{
var client = _configRepo.GetClient(clientName);
if (client == null)
return;
_container.RegisterInstance(client);
var modules = _container.ResolveAll<InterfaceExtension>().ToList();
modules.ForEach(module => _container.AddExtension(module));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment