/// <summary> /// Prevents a default instance of the ServiceLocator class from being created. /// </summary> private ServiceLocator() { this.sweeper.RegisterRegistrarProxy <IServiceLocationRegistrar>(new ServiceLocationRegistrarProxyFactory()); this.runtimeManager = new ServiceLocationRuntimeManager(this); this.runtimeServices.Add(typeof(IServiceLocationRuntimeManager), this.runtimeManager); this.runtimeServices.Add(typeof(IServiceLocationSimulationManager), new ServiceLocationSimulationManager(this)); this.runtimeServices.Add(typeof(IServiceLocationIndividualTestManager), new ServiceLocationIndividualTestManager(this)); this.runtimeServices.Add(typeof(IServiceLocationAssemblySweep), this.sweeper); this.runtimeServices.Add(typeof(IServiceLocator), this); this.RegisterAssemblies(); }
public void Register(ServiceLocation.IServiceLocationRuntimeManager manager, ServiceLocation.IServiceLocator locator) { if (ReferenceEquals(manager, null)) { throw new ArgumentNullException("manager"); } if (ReferenceEquals(locator, null)) { throw new ArgumentNullException("locator"); } var runtimeManager = new ServiceLocationRuntimeManager(); manager.RegisterInstance<IServiceLocationRuntimeManager>(runtimeManager); manager.RegisterType<IServiceLocationSimulationManager, ServiceLocationSimulationManager>(); manager.RegisterType<IServiceLocationIndividualTestManager, ServiceLocationIndividualTestManager>(); manager.RegisterInstance(ServiceLocator.Instance); var sweeper = locator.Locate<IServiceLocationAssemblySweep>(); sweeper.RegisterRegistrarProxy<IServiceLocationRegistrar>(new InternalServiceLocationRegistrarProxyFactory(runtimeManager, ServiceLocator.Instance)); }