private void RegisterServices() { RegistrationsCatalog catalog = new RegistrationsCatalog(); IEnumerable <Type> types = this.applicationAssemblies.SelectMany(a => a.GetTypes()); foreach (Type type in types) { for (int i = 0; i < this.behaviors.Count; i++) { IRegistrationBehavior behavior = this.behaviors[i]; IEnumerable <ServiceInfo> registrations = behavior.GetServicesFrom(type); foreach (ServiceInfo reg in registrations) { catalog.Add(reg, i); } } } foreach (ServiceInfo registration in catalog) { this.container.RegisterService(registration); } }
public void Run_RegistrationBehaviorReturnsOneService_TypeRegistered() { Type testType = typeof(TestType); ServiceInfo testSi = new ServiceInfo(testType, testType, "test contract", Lifetime.Instance); IRegistrationBehavior regBehaviorStub = GetRegBehaviorStub(testSi); Mock <IDependencyContainer> containerMock = GetFakeContainer(); Bootstrapper bootstrapper = this.GetTargetWithThisAssembly(containerMock); bootstrapper.AddRegistrationBehavior(regBehaviorStub); bootstrapper.Run(); containerMock.Verify(c => c.RegisterService(testSi), Times.AtLeastOnce); }
public virtual void AddRegistrationBehavior(IRegistrationBehavior behavior) { this.bootstrapper.AddRegistrationBehavior(behavior); }
public void AddRegistrationBehavior(IRegistrationBehavior behavior) { this.behaviors.Add(behavior); }
public static IBootstrapper AddRegistrationBehavior(this IBootstrapper bootstrapper, IRegistrationBehavior behavior) { bootstrapper.AddRegistrationBehavior(behavior); return(bootstrapper); }