Created
July 13, 2014 21:05
-
-
Save StacyGay/61f4bd0a7fe236d3fffe to your computer and use it in GitHub Desktop.
ExtensionLoader example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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