/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void EventHandler(IEvent evt) { /** * Map(CustomType, typeof(IEvent)). Dispatch(new CustomEvent(CustomType)). Make it inject IEvent * Map(CustomType). Dispatch(new Event(CustomType)). Make it inject IEvent * Map(CustomType). Dispatch(new CustomEvent(CustomType)). Make it inject CustomEvent * * Map(CustomType).typeof(CustomType) Dispatch(new Event(CustomType)). Make it not execute */ Type evtType = evt.GetType(); Type payloadEvtType = null; if (evtType == _eventClass || (_eventClass == null)) { payloadEvtType = (evtType == typeof(Event)) ? typeof(IEvent) : evtType; } else if (_eventClass == typeof(IEvent)) { payloadEvtType = _eventClass; payloadEvtType = typeof(IEvent); } else { return; } _executor.ExecuteCommands(_mappings.GetList(), new CommandPayload(new List <object> { evt }, new List <Type> { payloadEvtType })); }
/// <summary> /// Program entry point. /// </summary> /// <param name="args">The args.</param> static void Main(string[] args) { Mutex mutex = null; try { Console.WriteLine("**** Starting ****"); Console.WriteLine(" * Command line {0}", Environment.CommandLine); bool createdNew = false; mutex = new Mutex(false, "CodeCoverageUtil_Mutex", out createdNew); try { Console.WriteLine(" * Waiting for any running CodeCoverageUtil instances to complete."); mutex.WaitOne(); Console.WriteLine(" * No instances detected, starting now."); } catch (AbandonedMutexException) { } string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string defaultConfigFilePath = Path.Combine(currentDirectory, DefaultConfigFileName); #region Process Command Line Arguments CommandLineArguments commandLineArgs = CommandLineArguments.Parse(args); if (commandLineArgs.ShowHelp) { Console.WriteLine(CommandLineArguments.GetHelpMessage()); return; } if (!commandLineArgs.IsValid && !File.Exists(defaultConfigFilePath)) { ConsoleHelper.ConsoleWriteLine(ConsoleColor.Red, commandLineArgs.ErrorMessage); Console.WriteLine(); Console.WriteLine(CommandLineArguments.GetHelpMessage()); return; } string configFile = commandLineArgs.ConfigFilePath; if (string.IsNullOrEmpty(configFile) && File.Exists(defaultConfigFilePath)) { configFile = defaultConfigFilePath; } #endregion #region Load Configuration CodeCoverageUtilConfiguration config = new CodeCoverageUtilConfiguration(configFile); SessionInfo sessionInfo = new SessionInfo(commandLineArgs, config); if (sessionInfo.CommandLineArguments.TestAssemblies.Count > 0) { bool isValidTestAssembly = false; foreach (TestAssemblyConfig testAssemblyConfig in sessionInfo.Configuration.TestAssembliesConfig) { string fileName = Path.GetFileName(testAssemblyConfig.AssemblyPath).ToUpper(); int count = (from fn in sessionInfo.CommandLineArguments.TestAssemblies where Path.GetFileName(fn).ToUpper() == fileName select fn).Count(); if (count != 0) { isValidTestAssembly = true; break; } } if (!isValidTestAssembly) { Console.WriteLine(); ConsoleHelper.ConsoleWriteLine(ConsoleColor.Red, "None of the specified assemblies are valid test assemblies, exiting."); return; } } if (sessionInfo.TestCodeContext != null && !sessionInfo.TestCodeContext.IsValid) { Console.WriteLine(); ConsoleHelper.ConsoleWriteLine(ConsoleColor.Red, "The selected source line is invalid. Select either a namespace, class or method definition, exiting."); return; } #endregion #region Create and Run Commands if (Directory.Exists(sessionInfo.ResultsDirectory)) { Directory.Delete(sessionInfo.ResultsDirectory, true); } ICommandExecutor commandExecutor = CreateCommandExecutor(sessionInfo); List <Tuple <ICommand, string> > errors = commandExecutor.ExecuteCommands(); bool succeeded = (errors.Count == 0); #endregion #region Write Summary Information ConsoleColor summaryColor = ConsoleColor.Green; if (!succeeded) { summaryColor = ConsoleColor.Red; } Console.WriteLine(); ConsoleHelper.ConsoleWriteLine(summaryColor, "**** Summary ****"); if (!succeeded) { ConsoleHelper.ConsoleWriteLine(summaryColor, " * Failed. The following errors occurred:"); foreach (Tuple <ICommand, string> error in errors) { ConsoleHelper.ConsoleWriteLine(summaryColor, " * Command:{0}", error.Item1.Name); ConsoleHelper.ConsoleWriteLine(summaryColor, " * Error:{0}", error.Item2); Console.WriteLine(); } } else { if (config.KeepHistory) { string savedResultsDirectory = Path.Combine(config.ResultsPath, string.Format("{0}", DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"))); CopyDirectory(sessionInfo.ResultsDirectory, savedResultsDirectory); } ConsoleHelper.ConsoleWriteLine(summaryColor, " * Succeeded. Results written to directory: {0}", sessionInfo.ResultsDirectory); } if (commandLineArgs.ExploreToResultsFolder) { if (File.Exists(sessionInfo.CoverageResultsFile)) { Process.Start("explorer.exe", string.Format("/select,\"{0}\"", sessionInfo.CoverageResultsFile)); } else { Process.Start("explorer.exe", string.Format("/root,\"{0}\"", sessionInfo.ResultsDirectory)); } } if (commandLineArgs.OpenCoverageHtmlReport) { if (Directory.Exists(sessionInfo.CoverageReportDirectory)) { Process.Start(Path.Combine(sessionInfo.CoverageReportDirectory, "index.htm")); } } #endregion } catch (Exception ex) { ConsoleHelper.ConsoleWriteLine(ConsoleColor.Red, "An unexpected exception occurred. Error {0}", ex.ToString()); } finally { if (mutex != null) { mutex.ReleaseMutex(); mutex.Dispose(); } } }
public void Execute(CommandPayload payload) { _executor.ExecuteCommands(_mappings.GetList(), payload); }
public void Execute(Robotlegs.Bender.Extensions.CommandCenter.API.CommandPayload payload = null) { _executor.ExecuteCommands(_mappings.GetList(), payload); }
public void Execute(robotlegs.bender.extensions.commandCenter.api.CommandPayload payload = null) { _executor.ExecuteCommands(_mappings.GetList(), payload); }