public void Init() { IEnumerable <Assembly> assemblies = GetAssemblies(); bootstrapper = new Bootstrapper(assemblies); bootstrapper.ConfigureWithUnity(); bootstrapper.AddRegistrationBehavior(new ServiceRegistrationBehavior()); bootstrapper.AddRegistrationBehavior(DataAccessConfigurations.DefaultRegistrationConventions); bootstrapper.Run(); }
public static Bootstrapper Run() { var assemblies = GetApplicationAssemblies().ToArray(); Bootstrapper bootstrapper = new Bootstrapper(assemblies); bootstrapper.ConfigureWithUnity(); bootstrapper.AddRegistrationBehavior(new ServiceProxyRegistrationBehavior()); bootstrapper.AddRegistrationBehavior(new ServiceRegistrationBehavior()); bootstrapper.Run(); return(bootstrapper); }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); config.MapHttpAttributeRoutes(); var assemblies = this.GetApplicationAssemblies().ToArray(); Bootstrapper bootstrapper = new Bootstrapper(assemblies); bootstrapper.ConfigureWithUnity(); bootstrapper.AddRegistrationBehavior(new ServiceRegistrationBehavior()); bootstrapper.AddRegistrationBehavior(DataAccessConfigurations.DefaultRegistrationConventions); bootstrapper.Run(); bootstrapper.ConfigureWebApi(config); app.UseWebApi(config); }
public void Run_TypesOnSameInterfaceRegisteredByDifferentBehaviors_LastRegisteredBehaviorOverwrites() { DummyAssembly assembly = new DummyAssembly(typeof(Implementation), typeof(ProxyImpl)); DummyContainer dummyContainer = new DummyContainer(); IBootstrapper bootstrapper = new Bootstrapper(new[] { assembly }) .ConfigureWith(dummyContainer) .ConfigureWith(new Mock <IContextStore>().Object); IRegistrationBehavior proxyBeh = new DummyBehavior("Proxy"); IRegistrationBehavior serviceBeh = new DummyBehavior("Service"); bootstrapper.AddRegistrationBehavior(proxyBeh); bootstrapper.AddRegistrationBehavior(serviceBeh); bootstrapper.Run(); ServiceInfo resolved = dummyContainer.GetRegistration(typeof(IService)); Assert.Equal(typeof(Implementation), resolved.To); }
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); }