Esempio n. 1
0
        public static void Main(string[] args)
        {
            var isRunningAsConsole = IsApplicationRunningAsConsole(args);

            var writer = isRunningAsConsole
                              ? (IMessageWriter) new ConsoleWriter()
                              : (IMessageWriter) new EventLogWriter();

            if (IsApplicationAlreadyRunning())
            {
                writer.WriteError(StartupResources.ApplicationRunning);
                return;
            }

            var configurationFile = Path.Combine(
                DefaultConfigurationSettings.StoragePath, DefaultConfigurationSettings.ConfigurationFileName);

            if (args != null && args.Length > 0)
            {
                configurationFile = DetermineConfigurationFileFromArgs(args);
            }

            if (configurationFile == null)
            {
                writer.WriteError(StartupResources.InvalidArguments + string.Join(@" ", args));

                if (isRunningAsConsole)
                {
                    writer.Information(StartupResources.HelpInformation);
                }

                return;
            }

            var configurationDal = new ConfigurationDataAccess(configurationFile);
            var configuration    = new StumpsConfiguration(configurationDal);

            configurationDal.EnsureConfigurationIsInitialized(configuration.SaveConfiguration);

            configuration.LoadConfiguration();

            var startup = isRunningAsConsole ? (IStartup) new ConsoleStartup() : (IStartup) new ServiceStartup();

            startup.Configuration = configuration;
            startup.MessageWriter = writer;

            startup.RunInstance();
        }
Esempio n. 2
0
        public static void Main()
        {
            var configurationFile = Path.Combine(
                DefaultConfigurationSettings.StoragePath, DefaultConfigurationSettings.ConfigurationFileName);

            var configurationDal = new ConfigurationDataAccess(configurationFile);
            var configuration    = new StumpsConfiguration(configurationDal);

            configurationDal.EnsureConfigurationIsInitialized(configuration.SaveConfiguration);

            configuration.LoadConfiguration();

            var urlString = string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", configuration.WebApiPort);

            Process.Start(urlString);
        }