void ISetupDescriptor.RegisterWithServiceLocator <T>(Lazy <TIService> service, Lazy <IServiceLocator> locator, string name) { if (service == null) { throw new ArgumentNullException("service"); } if (locator == null) { throw new ArgumentNullException("locator", "Unable to locate ServiceLocator, please ensure this is defined first."); } if (!locator.IsValueCreated) { var descriptor = ServiceLocatorManager.GetSetupDescriptor(locator); if (descriptor == null) { throw new NullReferenceException(); } descriptor.Do(l => RegisterInstance <T>((T)service.Value, l, name)); } else { var descriptor = GetSetupDescriptorProtected(service, null); if (descriptor == null) { throw new NullReferenceException(); } descriptor.Do(l => RegisterInstance <T>((T)service.Value, locator.Value, name)); } }
void ISetupDescriptor.RegisterWithServiceLocator(Lazy <TIService> service, Lazy <IServiceLocator> locator, string name) { if (service == null) { throw new ArgumentNullException("service"); } if (locator == null) { throw new ArgumentNullException("locator", "Unable to locate ServiceLocator, please ensure this is defined first."); } var serviceRegistrar = _registration.DefaultServiceRegistrar; if (serviceRegistrar == null) { throw new NullReferenceException("registration.ServiceLocatorRegistrar"); } if (!locator.IsValueCreated) { // question: should this use RegisterWithServiceLocator below? var descriptor = ServiceLocatorManager.GetSetupDescriptor(locator); if (descriptor == null) { throw new NullReferenceException(); } descriptor.Do(l => serviceRegistrar(service.Value, l, name)); } else { var descriptor = GetSetupDescriptorProtected(service, null); if (descriptor == null) { throw new NullReferenceException(); } descriptor.Do(s => serviceRegistrar(s, locator.Value, name)); } }