コード例 #1
0
        public void Init()
        {
            IEnumerable <Assembly> assemblies = GetAssemblies();

            bootstrapper = new Bootstrapper(assemblies);
            bootstrapper.ConfigureWithUnity();
            bootstrapper.AddRegistrationBehavior(new ServiceRegistrationBehavior());
            bootstrapper.AddRegistrationBehavior(DataAccessConfigurations.DefaultRegistrationConventions);

            bootstrapper.Run();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: razvanticle/Ergate
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }