private static void tryStartApplication(string[] args) { try { if (userWantedCommandLineHelpPrinted(args)) return; var arguments = getPossibleCommandArgs(args); string directoryToWatch = null; if (arguments.WatchToken != null) { var tokenExists = Directory.Exists(arguments.WatchToken) || File.Exists(arguments.WatchToken); if (arguments.WatchToken.Contains(".." + Path.DirectorySeparatorChar) || !tokenExists) directoryToWatch = new PathParser(Environment.CurrentDirectory).ToAbsolute(arguments.WatchToken); else directoryToWatch = arguments.WatchToken; } if ((directoryToWatch = ConfigureApplication(directoryToWatch)) == null) return; var overviewForm = BootStrapper.Services.Locate<IOverviewForm>(); overviewForm.SetWatchDirectory(directoryToWatch); notifyOnLoggingSetup(); using (var watcher = BootStrapper.Services.Locate<IDirectoryWatcher>()) { if (arguments.ConfigurationLocation != null) { var configurationLocation = arguments.ConfigurationLocation; if (Directory.Exists(Path.Combine(directoryToWatch, configurationLocation))) configurationLocation = Path.Combine(directoryToWatch, configurationLocation); watcher.LocalConfigurationIsLocatedAt(configurationLocation); } watcher.Watch(directoryToWatch); var proxy = BootStrapper.Services.Locate<IMessageProxy>(); proxy.SetMessageForwarder(overviewForm.Form); Application.Run(overviewForm.Form); } BootStrapper.ShutDown(); } catch (Exception exception) { logException(exception); } }
public void BuildIgnoreListFromPath(string watchPath) { var file = new PathParser(_ignoreFile).ToAbsolute(watchPath); Debug.WriteDebug("Using ignore file {0}", file); if (File.Exists(file)) WatchIgnoreList = getLineArrayFromFile(file, watchPath); else WatchIgnoreList = new string[] { }; }
static void Main(string[] args) { var exit = false; Console.CancelKeyPress += delegate { exit = true; }; var arguments = ArgumentParser.Parse(args); if (arguments.Help) { Console.WriteLine("AutoTest.Server.exe command line arguments"); Console.WriteLine(""); Console.WriteLine("To specify watch directory on startup you can type:"); Console.WriteLine("\tAutoTest.WinForms.exe [WATCH_DIRECTORY] [--local-config-location=/path]"); return; } string token = null; if (arguments.WatchToken != null) { var tokenExists = Directory.Exists(arguments.WatchToken) || File.Exists(arguments.WatchToken); if (arguments.WatchToken.Contains(".." + Path.DirectorySeparatorChar) || !tokenExists) token = new PathParser(Environment.CurrentDirectory).ToAbsolute(arguments.WatchToken); else token = arguments.WatchToken; } else { token = Environment.CurrentDirectory; } var watchDirectory = token; if (File.Exists(token)) watchDirectory = Path.GetDirectoryName(token); BootStrapper.Configure(); Debug.EnableLogging(new ConsoleWriter()); BootStrapper.Container .Register( Component.For<IMessageProxy>() .Forward<IRunFeedbackView>() .Forward<IInformationFeedbackView>() .Forward<IConsumerOf<AbortMessage>>() .ImplementedBy<MessageProxy>().LifeStyle.Singleton); var proxy = BootStrapper.Services.Locate<IMessageProxy>(); using (var server = new MessageEndpoint(watchDirectory, createHandlers(), proxy)) { proxy.SetMessageForwarder(server); BootStrapper.Services.Locate<IRunResultCache>().EnabledDeltas(); BootStrapper.InitializeCache(token); using (var watcher = BootStrapper.Services.Locate<IDirectoryWatcher>()) { if (arguments.ConfigurationLocation != null) { var configurationLocation = arguments.ConfigurationLocation; if (Directory.Exists(Path.Combine(token, configurationLocation))) configurationLocation = Path.Combine(token, configurationLocation); watcher.LocalConfigurationIsLocatedAt(configurationLocation); } watcher.Watch(token); while (!exit && server.IsAlive) { Thread.Sleep(100); } Console.WriteLine("exiting"); } Console.WriteLine("shutting down"); BootStrapper.ShutDown(); Console.WriteLine("disposing server"); } Console.WriteLine("done"); }
static void run(string localConfig, string path, IStartupHandler handler) { if (localConfig != null) { var parser = new PathParser(localConfig); if (Directory.Exists(Path.Combine(path, localConfig))) localConfig = parser.ToAbsolute(path); } Logger.SetListener(new FileLogger()); Client = new ATEClient(); Client.Start(new StartupParams(path, localConfig), handler); }