Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            try
            {
                System.Console.ForegroundColor = ConsoleColor.White;
                System.Console.WriteLine("Starting ImageService.....please wait");
                log4net.Config.XmlConfigurator.Configure();

                IConfigManager configManager = CastleContainer.Resolve <IConfigManager>();
                ((IAsyncInitialization)configManager).Initialization.Wait();
                string baseAddress = "https://+:27071/";

                // Start OWIN host
                var options = new StartOptions
                {
                    AppStartup = typeof(ApiStartup).AssemblyQualifiedName
                };
                options.Urls.Add(baseAddress);

                _webApplication = WebApp.Start <ApiStartup>(options);
                System.Console.WriteLine("Image Service Started sucessfully. Press <ENTER> to stop");
                System.Console.ReadKey();
                _webApplication.Dispose();
            }
            catch (Exception exception)
            {
                if (null != _webApplication)
                {
                    _webApplication.Dispose();
                }
                System.Console.WriteLine(exception.Message);
            }
        }
 public void when_registering_already_registered_configuration_then_it_should_throw_container_exception()
 {
     var sut = new CastleContainer();
     sut.Register<given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();
     sut.Register<given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();
     Assert.Fail("Should have thrown an exception");
 }
        public void when_resolving_whats_is_not_there_should_wrap_original_exception_with_container_exception()
        {
            var sut = new CastleContainer();

            sut.Get <given_a_simple_container.Interfaze>();
            Assert.Fail("Should have thrown an exception");
        }
        public void when_registering_already_registered_configuration_then_it_should_throw_container_exception()
        {
            var sut = new CastleContainer();

            sut.Register <given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();
            sut.Register <given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();
            Assert.Fail("Should have thrown an exception");
        }
        public void when_resolving_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock<IWindsorContainer>(MockBehavior.Loose);
            var sut = new CastleContainer(inner.Object);

            sut.Get<given_a_simple_container.Interfaze>();

            inner.Verify(x => x.Resolve<given_a_simple_container.Interfaze>());
        }
        public void when_resolving_all_with_type_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock <IWindsorContainer>(MockBehavior.Loose);
            var sut   = new CastleContainer(inner.Object);

            sut.GetAll(typeof(given_a_simple_container.Interfaze));

            inner.Verify(x => x.ResolveAll(It.Is <Type>(x1 => x1.Equals(typeof(given_a_simple_container.Interfaze)))));
        }
        public void when_resolving_all_with_type_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock<IWindsorContainer>(MockBehavior.Loose);
            var sut = new CastleContainer(inner.Object);

            sut.GetAll(typeof(given_a_simple_container.Interfaze));

            inner.Verify(x => x.ResolveAll(It.Is<Type>(x1 => x1.Equals(typeof (given_a_simple_container.Interfaze)))));
        }
        public void when_resolving_all_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock <IWindsorContainer>(MockBehavior.Loose);
            var sut   = new CastleContainer(inner.Object);

            sut.GetAll <given_a_simple_container.Interfaze>();

            inner.Verify(x => x.ResolveAll <given_a_simple_container.Interfaze>());
        }
        public void when_resolving_with_name_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock <IWindsorContainer>(MockBehavior.Loose);
            var sut   = new CastleContainer(inner.Object);

            sut.Get <given_a_simple_container.Interfaze>("anonymousName");

            inner.Verify(
                x => x.Resolve <given_a_simple_container.Interfaze>(It.Is <string>(x1 => x1.Equals("anonymousName"))));
        }
Ejemplo n.º 10
0
        protected virtual void Initialize()
        {
            Logger.Debug("Installing dependencies");
            CastleContainer.Install(FromAssembly.This());

            if (DoRunWebHost)
            {
                Logger.Debug("Starting web host");
                WebHost = WebApp.Start(ServiceAppSettings.SignalRUrl);
            }
        }
        /// <summary>
        /// 	Creates this instance.
        /// </summary>
        /// <param name="configuration"> The configuration. </param>
        /// <returns> An instance of the Container </returns>
        public IDexterContainer Create(string configuration)
        {
            CastleContainer castle = new CastleContainer();
            if (!string.IsNullOrEmpty(configuration))
            {
                configuration = HttpContext.Current != null ? HttpContext.Current.Server.MapPath(configuration) : string.Concat(AppDomain.CurrentDomain.BaseDirectory, configuration.Replace("~/", string.Empty));
            }

            castle.Configure(configuration);

            return castle;
        }
Ejemplo n.º 12
0
        public void when_registering_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock <IWindsorContainer>(MockBehavior.Loose);
            var sut   = new CastleContainer(inner.Object);

            sut.Register <given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();

            inner.Verify(
                x => x.Register(Match.Create <IRegistration[]>(x1 => x1.Contains(
                                                                   Component.For <given_a_simple_container.Interfaze>()
                                                                   .ImplementedBy <given_a_simple_container.Clazz>()
                                                                   .LifeStyle.Transient))));
        }
        public void when_registering_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock<IWindsorContainer>(MockBehavior.Loose);
            var sut = new CastleContainer(inner.Object);

            sut.Register<given_a_simple_container.Interfaze, given_a_simple_container.Clazz>();

            inner.Verify(
                x => x.Register(Match.Create<IRegistration[]>(x1 => x1.Contains(
                    Component.For<given_a_simple_container.Interfaze>()
                    .ImplementedBy<given_a_simple_container.Clazz>()
                    .LifeStyle.Transient))));
        }
        public void Context()
        {
            _windsorContainer = new WindsorContainer();

            _windsorContainer.Register(
                Component.For <IServiceType>()
                .ImplementedBy <ServiceType>()
                .LifeStyle.Transient
                );

            var castleContainer = new CastleContainer(_windsorContainer);

            _result = castleContainer.Resolve <IServiceType>();
        }
Ejemplo n.º 15
0
        public IServiceProvider ConfigureServices(IServiceCollection services, Action action)
        {
            // Configure regular ASP.NET Core services
            services.AddMvc();

            var container = new CastleContainer();

            DependencyContainer.SetContainer(container);

            container.Container.Populate(services);

            Bootstrapper.Initialise();
            action();

            container.Container.BeginScope();
            return(DependencyContainer.Container.Resolve <IServiceProvider>());
        }
Ejemplo n.º 16
0
        public virtual bool Stop(HostControl hostControl)
        {
            Logger.Info("Stopping service");

            if (GameLoopCancellationTokenSource != null)
            {
                GameLoopCancellationTokenSource.Cancel();
            }

            if (WebHost != null)
            {
                WebHost.Dispose();
            }

            CastleContainer.Dispose();

            return(true);
        }
        public CastleContainerTest()
        {
            this.sut = new CastleContainer();

            this.sut.Configure(null);
        }
 public void Dispose()
 {
     this.sut.Shutdown();
     this.sut = null;
 }
Ejemplo n.º 19
0
        public virtual void Context()
        {
            WindsorContainer = Stub<IWindsorContainer>();

            CastleContainer = new CastleContainer(WindsorContainer);
        }
Ejemplo n.º 20
0
 public void Init()
 {
     _container = new CastleContainer();
     _container.Register <NamedDummy, NamedDummy>();
     _container.Register <UnnamedDummy, UnnamedDummy>();
 }
 public void Dispose()
 {
     this.sut.Shutdown();
     this.sut = null;
 }
 public void when_resolving_whats_is_not_there_should_wrap_original_exception_with_container_exception()
 {
     var sut = new CastleContainer();
     sut.Get<given_a_simple_container.Interfaze>();
     Assert.Fail("Should have thrown an exception");
 }
        public void when_resolving_with_name_obviously_should_delegate_to_underlying_container()
        {
            var inner = new Mock<IWindsorContainer>(MockBehavior.Loose);
            var sut = new CastleContainer(inner.Object);

            sut.Get<given_a_simple_container.Interfaze>("anonymousName");

            inner.Verify(
                x => x.Resolve<given_a_simple_container.Interfaze>(It.Is<string>(x1 => x1.Equals("anonymousName"))));
        }
        public CastleContainerTest()
        {
            this.sut = new CastleContainer();

            this.sut.Configure(null);
        }