protected override void OnExit(object sender, EventArgs e)
        {
            //TODO fix ConEmu errors on close...

            _container?.Dispose();
            Environment.Exit(0);
        }
Exemple #2
0
        private static void RunTheHostFactory(IWindsorContainer container)
        {
            HostFactory.Run(config =>
                {
                    config.Service<IGenericService>(settings =>
                        {
                            settings.ConstructUsing(hostSettings => container.Resolve<IGenericService>());
                            settings.WhenStarted(service => service.Start());
                            settings.WhenStopped(service =>
                                {
                                    service.Stop();
                                    container.Release(service);
                                    container.Dispose();
                                });
                            settings.WhenPaused(service => { });
                            settings.WhenContinued(service => { });
                        });

                    config.RunAsLocalSystem();

                    var serviceDescription = container.Resolve<ServiceDescription>();
                    config.SetDescription(serviceDescription.Description);
                    config.SetDisplayName(serviceDescription.DisplayName);
                    config.SetServiceName(serviceDescription.ServiceName);
                });
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         container?.Dispose();
     }
 }
 public void all_registered_types()
 {
     sut = WindsorContainerFactory.Create(false);
     foreach (var handler in sut.Kernel.GetAssignableHandlers(typeof (object)))
         Console.WriteLine("{0} {1}", handler.ComponentModel.Service, handler.ComponentModel.Implementation);
     sut.Dispose();
 }
        static void Main(string[] args)
        {
            container = BotRunnerBootstrapper.Init();

            var fineBot = new Bot();
            var fineBotResponders = container.ResolveAll<IFineBotResponder>();
            foreach (IFineBotResponder responder in fineBotResponders)
            {
                fineBot.Responders.Add(responder);
            }

            fineBot.RespondsTo("hi").IfBotIsMentioned().With("Stop resisting citizen!");
            fineBot.CreateResponder(x => !x.BotHasResponded, rc => "My responses are limited, you must ask the right question...");

            var task = fineBot.Connect(ConfigurationManager.AppSettings["BotKey"]);
            Console.WriteLine(string.Format("{0}: Bot is runnning, type 'die' to make it die", DateTime.Now));

            var secondCousinBot = new Bot();
            var secondCousinResponders = container.ResolveAll<ISecondCousinResponder>();
            foreach (ISecondCousinResponder responder in secondCousinResponders)
            {
                secondCousinBot.Responders.Add(responder);
            }
            var seconderTask = secondCousinBot.Connect(ConfigurationManager.AppSettings["SeconderBotKey"]);
            Console.WriteLine(string.Format("{0}: Finebot's second cousin is also also running. Some say he can't die.", DateTime.Now));

            while(Console.ReadLine() != "die")
            {

            }

            container.Dispose();
        }
 public void resolve_with_Web_config()
 {
     sut = WindsorContainerFactory.Create(true);
     Assert.IsInstanceOf(typeof(WebCacheManager), sut.Resolve<ICacheManager>());
     Assert.IsInstanceOf(typeof(TerminalTasks), sut.Resolve<ITerminalTasks>());
     resolve_common_types();
     sut.Dispose();
 }
Exemple #7
0
 public static void Dispose()
 {
     lock (sync)
     {
         innerContainer?.Dispose();
         innerContainer = null;
     }
 }
 public void Create_WindsorContainer_from_WindsorContainerFactory()
 {
     sut = WindsorContainerFactory.Create(false);
     foreach(var g in sut.Kernel.GraphNodes)
         if(g.Dependers.Length == 0) {
             Console.WriteLine();
             WalkGraph(g, 0);
         }
     sut.Dispose();
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         client?.Dispose();
         tokenSource?.Dispose();
         container?.Dispose();
         handler?.Dispose();
     }
 }
        /// <summary>
        ///     Handles the End event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        private void Application_End(object sender, EventArgs e)
        {
            _log.Information("[stopping]");

            _bus?.Dispose();
            _container?.Dispose();

            _log.Information("[stopped]");

            LogManager.Shutdown();
        }
 public void resolve_with_Wpf_configuration()
 {
     sut = WindsorContainerFactory.Create(false);
     Assert.IsInstanceOf(typeof(WinCacheManager), sut.Resolve<ICacheManager>());
     Assert.IsInstanceOf(typeof(EventWrappedTerminalTasks), sut.Resolve<ITerminalTasks>());
     Assert.IsInstanceOf(typeof(EventWrappedTerminalTasks), sut.Resolve<ITerminalEvents>());
     Assert.AreSame(sut.Resolve<ITerminalTasks>(), sut.Resolve<ITerminalEvents>());
     Assert.IsInstanceOf(typeof(ScopedTerminalTasks), sut.Resolve<ITerminalTasks>(typeof(ScopedTerminalTasks).FullName));
     Assert.IsInstanceOf(typeof(TerminalTasks), sut.Resolve<ITerminalTasks>(typeof(TerminalTasks).FullName));
     resolve_common_types();
     sut.Dispose();
 }
Exemple #12
0
 private void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (!disposing)
     {
         return;
     }
     _container?.Dispose();
     _container = null;
     _disposed  = true;
 }
Exemple #13
0
 protected virtual void Dispose(bool disposing)
 {
     if (Disposed)
     {
         return;
     }
     if (disposing)
     {
         CancelAll.Cancel();
         Container?.Dispose();
         Container = null;
     }
     Disposed = true;
 }
        public static void Main(string[] args)
        {
            Console.WriteLine("Starting Main");

            container=new WindsorContainer();

            container.Install(
                 FromAssembly.This()
            );

            IMain app=container.Resolve<IMain>();
            app.Begin();
            app.AddSomeBlogs();
            app.GetBlogByTitle("Blog 3");
            app.AddSomeCommentsTo("Blog 3");
            app.CountAllComments();
            Console.Write("Completed.");

            container.Dispose();
            Console.ReadKey(true);
        }
Exemple #15
0
        private static void RunTheHostFactory(IWindsorContainer container)
        {
            HostFactory.Run(config =>
            {
                config.Service<IHostedService>(settings =>
                {
                    settings.ConstructUsing(hostSettings =>
                    {
                        var service = container.Resolve<IHostedService>();
                        return service;
                    });
                    settings.WhenStarted(service => service.Start());
                    settings.WhenStopped(service =>
                    {
                        service.Stop();
                        container.Release(service);
                        container.Dispose();
                    });
                    settings.WhenPaused(service => service.Pause());
                    settings.WhenContinued(service => service.Continue());
                });

                config.BeforeInstall(() =>
                {
                });
                config.AfterUninstall(() =>
                {
                });

                config.RunAsLocalSystem();

                var serviceDescription = container.Resolve<ServiceDescription>();
                config.SetDescription(serviceDescription.Description);
                config.SetDisplayName(serviceDescription.DisplayName);
                config.SetServiceName(serviceDescription.ServiceName);

                config.DependsOnEventLog();
            });
        }
Exemple #16
0
        static void Main(string[] args)
        {
            container = BotRunnerBootstrapper.Init();

            Bot bot = new Bot();

            foreach(IResponder responder in container.ResolveAll<IResponder>())
            {
                bot.Responders.Add(responder);
            }

            bot.RespondsTo("hi").IfBotIsMentioned().With("Stop resisting citizen!");

            var task = bot.Connect(ConfigurationManager.AppSettings["SlackApiKey"]);

            Console.WriteLine(String.Format("{0}: Bot is runnning, type 'die' to make it die", DateTime.Now));

            while(Console.ReadLine() != "die")
            {

            }

            container.Dispose();
        }
Exemple #17
0
 public void TestFixtureTeardown()
 {
     HttpContext.Current = null;
     container.Dispose();
 }
Exemple #18
0
 public void Terminate()
 {
     container.Dispose();
 }
Exemple #19
0
 public void Stop()
 {
     _bus?.Dispose();
     _container?.Dispose();
 }
Exemple #20
0
 public Boolean Stop()
 {
     _container.Dispose();
     return(true);
 }
Exemple #21
0
        protected void GenerateContainer()
        {
            _container?.Dispose(); //if we already registered container, just dispose the old one.
            _container = new WindsorContainer();

            _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel, true));
            _container.Kernel.Resolver.AddSubResolver(new ArrayResolver(_container.Kernel, true));

            _container.AddFacility <JarvisTypedFactoryFacility>();
            _loggerInstance = new TestLogger("Test", LoggerLevel.Info);
            _container.Register(
                Component
                .For <ILogger>()
                .Instance(_loggerInstance),
                Component
                .For <ILoggerFactory>()
                .AsFactory(),
                Component
                .For <INStoreLoggerFactory>()
                .ImplementedBy <NStoreCastleLoggerFactory>(),
                Component
                .For <IMongoDatabase>()
                .Instance(_db),
                Component
                .For <IPersistence>()
                .Instance(_persistence),
                Component
                .For <IIdentityManager, IIdentityConverter>()
                .Instance(_identityManager),
                Component
                .For <ICommitEnhancer>()
                .ImplementedBy <CommitEnhancer>(),
                Component
                .For <AtomicProjectionCheckpointManager>(),
                Component
                .For <AtomicProjectionEngine>()
                .ImplementedBy <AtomicProjectionEngine>(),
                Component
                .For <ILiveAtomicReadModelProcessor>()
                .ImplementedBy <LiveAtomicReadModelProcessor>(),
                Component
                .For <ICommitPollingClient>()
                .ImplementedBy <CommitPollingClient2>()
                .LifeStyle.Transient,
                Component
                .For <IAtomicReadModelFactory>()
                .ImplementedBy <AtomicReadModelFactory>(),
                Component
                .For <IAtomicReadmodelProjectorHelperFactory>()
                .ImplementedBy <AtomicReadmodelProjectorHelperFactory>()
                .DependsOn(Dependency.OnValue <IWindsorContainer>(_container)),    //I Know, this is not optima, we will refactor this to a facility.
                Component
                .For <ICommitPollingClientFactory>()
                .AsFactory(),
                Component.For(typeof(AtomicReadmodelProjectorHelper <>))
                .ImplementedBy(typeof(AtomicReadmodelProjectorHelper <>)),
                Component
                .For(new Type[]
            {
                typeof(IAtomicMongoCollectionWrapper <>),
                typeof(IAtomicCollectionWrapper <>),
                typeof(IAtomicCollectionReader <>),
            })
                .ImplementedBy(typeof(AtomicMongoCollectionWrapper <>))
                .Named("AtomicMongoCollectionWrapper"),
                Component
                .For <IAtomicCollectionWrapperFactory>()
                .AsFactory(),
                Component
                .For <AtomicReadModelSignatureFixer>()
                .LifestyleTransient()
                );
        }
Exemple #22
0
 public static void Release(IWindsorContainer container)
 {
     container.Dispose();
 }
Exemple #23
0
 public static void Reset()
 {
     _container?.Dispose();
     _container = new WindsorContainer();
 }
Exemple #24
0
 /// <summary> </summary>
 public void Application_OnEnd()
 {
     container.Dispose();
 }
 public void TearDown()
 {
     _container.Dispose();
 }
Exemple #26
0
 public void Cleanup()
 {
     _container.Dispose();
 }
 public void Dispose()
 {
     windsorContainer.Dispose();
 }
Exemple #28
0
 public static void DisposeContainer()
 {
     container.Dispose();
 }
Exemple #29
0
 public void Close_container()
 {
     _container.Dispose();
 }
 public void Teardown()
 {
     container.Dispose();
 }
 /// <summary>
 /// Releases the container.
 /// </summary>
 public static void ReleaseContainer()
 {
     Container.Dispose();
 }
Exemple #32
0
 public override void Dispose()
 {
     container.Dispose();
 }
Exemple #33
0
 protected void Application_End(object sender, EventArgs e)
 {
     _container?.Dispose();
 }
Exemple #34
0
 public void Dispose()
 {
     _container.Dispose();
 }
 public void TearDown()
 {
     _containerToDisposeAfterTest?.Dispose();
 }
 internal static void Shutdown()
 {
     container.Dispose();
 }
Exemple #37
0
 public static void Shutdown()
 {
     _container?.Dispose();
 }
Exemple #38
0
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     _scope?.Dispose();
     _container.Dispose();
 }
Exemple #39
0
 protected void Application_End()
 {
     _container.Dispose();
 }
 protected override void OnExit(object sender, EventArgs e)
 {
     container.Dispose();
     base.OnExit(sender, e);
 }