public void ContainerResolvesServiceLocatorAfterStandardConfigurationAndInstallCoreExtensions() { var container = new UnityContainer(); container.StandardConfiguration(); container.InstallCoreExtensions(); var candidate = container.Resolve<IServiceLocator>(); }
public static UnityContainer Create() { var container = new UnityContainer(); container.InstallCoreExtensions(); // Self-register and set up service location container.RegisterInstance<IUnityContainer>(container); var locator = new UnityServiceLocator(container); ServiceLocator.SetLocatorProvider(() => locator); return container; }
public static UnityContainer Create() { var container = new UnityContainer(); container.InstallCoreExtensions(); // Configurator will read Enterprise Library configuration // and set up the container var configurator = new UnityContainerConfigurator(container); // Configuration source holds the new configuration we want to use // load this in your own code IConfigurationSource configSource = new SystemConfigurationSource(true); // Configure the container EnterpriseLibraryContainer.ConfigureContainer(configurator, configSource); // Self-register and set up service location container.RegisterInstance<IUnityContainer>(container); var locator = new UnityServiceLocator(container); ServiceLocator.SetLocatorProvider(() => locator); return container; }