BottomShelf.Host.BottomShelfHost.Start C# (CSharp) Method

Start() public method

public Start ( CommandLineParameters parameters ) : void
parameters CommandLineParameters
return void
        public void Start(CommandLineParameters parameters)
        {
            logger.Info("Starting BottomShelf host.");

            var servicesDirectory = Path.GetFullPath(parameters.ServicesDirectory);
            watcher = new FileSystemWatcher(servicesDirectory, parameters.FileSystemPoll);

            hostedServices = new AssemblyScanner().Scan(servicesDirectory);
            hostedServices.ForEach(hs => StartHostedService(hs, watcher));

            watcher.Start();

            logger.Info("Started monitoring changes in '{0}'.", servicesDirectory);
        }

Usage Example

Example #1
0
        private static void Main(string[] arguments)
        {
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            var parameters = new CommandLineParameters();

            if(!parser.ParseArguments(arguments, parameters))
                Environment.Exit(1);

            InstallOrUninstallWindowsServiceIfNecessary(parameters);

            var bottomShelfHost = new BottomShelfHost();

            if(Environment.UserInteractive)
            {
                bottomShelfHost.Start(parameters);
                WaitUntilUserWantsToExit();
                bottomShelfHost.Stop();

                Environment.Exit(0);
            }

            ServiceBase.Run(new BottomShelfService(bottomShelfHost));
        }