public IEnumerable <IComponentRegistration> RegistrationsFor(Service service, Func <Service, IEnumerable <IComponentRegistration> > registrationAccessor) { if (service == null) { throw new ArgumentNullException("service"); } if (registrationAccessor == null) { throw new ArgumentNullException("registrationAccessor"); } Type constructedImplementationType; IEnumerable <Service> services; if (OpenGenericServiceBinder.TryBindServiceType(service, _registrationData.Services, _activatorData.ImplementationType, out constructedImplementationType, out services)) { var swt = (IServiceWithType)service; var fromService = _activatorData.FromService.ChangeType(swt.ServiceType); return(registrationAccessor(fromService) .Select(cr => RegistrationBuilder.CreateRegistration( Guid.NewGuid(), _registrationData, new ReflectionActivator( constructedImplementationType, _activatorData.ConstructorFinder, _activatorData.ConstructorSelector, AddDecoratedComponentParameter(swt.ServiceType, cr, _activatorData.ConfiguredParameters), _activatorData.ConfiguredProperties), services))); } return(Enumerable.Empty <IComponentRegistration>()); }
public IEnumerable <IComponentRegistration> RegistrationsFor(Service service, Func <Service, IEnumerable <IComponentRegistration> > registrationAccessor) { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (registrationAccessor == null) { throw new ArgumentNullException(nameof(registrationAccessor)); } Type constructedImplementationType; IEnumerable <Service> services; if (OpenGenericServiceBinder.TryBindServiceType(service, _registrationData.Services, _activatorData.ImplementationType, out constructedImplementationType, out services)) { yield return(RegistrationBuilder.CreateRegistration( Guid.NewGuid(), _registrationData, new ReflectionActivator( constructedImplementationType, _activatorData.ConstructorFinder, _activatorData.ConstructorSelector, _activatorData.ConfiguredParameters, _activatorData.ConfiguredProperties), services)); } }