Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public virtual void AddRegistrationBehavior(IRegistrationBehavior behavior)
 {
     this.bootstrapper.AddRegistrationBehavior(behavior);
 }
Esempio n. 4
0
 public void AddRegistrationBehavior(IRegistrationBehavior behavior)
 {
     this.behaviors.Add(behavior);
 }
Esempio n. 5
0
 public static IBootstrapper AddRegistrationBehavior(this IBootstrapper bootstrapper, IRegistrationBehavior behavior)
 {
     bootstrapper.AddRegistrationBehavior(behavior);
     return(bootstrapper);
 }