public static void DumpValidationResults(IEnumerable <ValidationResult> results)
        {
            ArgumentUtility.CheckNotNull("results", results);

            foreach (ValidationResult result in results)
            {
                if (result.TotalRulesExecuted == 0)
                {
                    //Console.ForegroundColor = ConsoleColor.DarkGray;
                    //Console.WriteLine ("No rules found for {0} '{1}'", result.Definition.GetType ().Name, result.Definition.FullName);
                }
                else if (result.TotalRulesExecuted != result.Successes.Count)
                {
                    using (ConsoleUtility.EnterColorScope(ConsoleColor.Gray, null))
                    {
                        Console.WriteLine(
                            "{0} '{1}', {2} rules executed",
                            result.ValidatedDefinition.GetType().Name,
                            result.ValidatedDefinition.FullName,
                            result.TotalRulesExecuted);
                        DumpContext(result);
                    }
                }
                DumpResultList("unexpected exceptions", result.Exceptions, ConsoleColor.White, ConsoleColor.DarkRed);
                // DumpResultList ("successes", result.Successes, ConsoleColor.Green, null);
                DumpResultList("warnings", result.Warnings, ConsoleColor.Yellow, null);
                DumpResultList("failures", result.Failures, ConsoleColor.Red, null);
            }
        }
Esempio n. 2
0
 public virtual int RunApplication(TApplicationSettings settings)
 {
     try
     {
         var application = CreateApplication();
         application.Run(settings, _errorWriter, _logWriter);
     }
     catch (Exception e)
     {
         //_result = 1;
         using (ConsoleUtility.EnterColorScope(ConsoleColor.White, ConsoleColor.DarkRed))
         {
             _errorWriter.WriteLine("Execution aborted. Exception stack:");
             for (; e != null; e = e.InnerException)
             {
                 _errorWriter.Write(e.GetType().FullName);
                 _errorWriter.Write(": ");
                 _errorWriter.WriteLine(e.Message);
                 _errorWriter.WriteLine(e.StackTrace);
                 _errorWriter.WriteLine();
             }
         }
         return(1);
     }
     return(0);
 }
Esempio n. 3
0
 void Mixer_ErrorOccurred(object sender, ErrorEventArgs e)
 {
     using (ConsoleUtility.EnterColorScope(ConsoleColor.Red, null))
     {
         Console.WriteLine(e.Exception.ToString());
     }
 }
Esempio n. 4
0
 private void Mixer_ValidationErrorOccurred(object sender, ValidationErrorEventArgs e)
 {
     using (ConsoleUtility.EnterColorScope(ConsoleColor.Red, null))
     {
         Console.WriteLine(e.ValidationException.Message);
     }
 }
 private static void DumpResultList <T> (string title, List <T> resultList, ConsoleColor foreColor, ConsoleColor?backColor) where T : IDefaultValidationResultItem
 {
     if (resultList.Count > 0)
     {
         using (ConsoleUtility.EnterColorScope(foreColor, backColor))
         {
             Console.WriteLine("  {0} - {1}", title, resultList.Count);
             foreach (T resultItem in resultList)
             {
                 Console.WriteLine("    {0} ({1})", resultItem.Message, resultItem.RuleName);
             }
         }
     }
 }
Esempio n. 6
0
        protected override void CrossAppDomainCallbackHandler()
        {
            ConfigureLogging();

            Mixer mixer = CreateMixer();

            try
            {
                mixer.PrepareOutputDirectory();
                mixer.Execute(MixinConfiguration.ActiveConfiguration);
            }
            catch (Exception ex)
            {
                using (ConsoleUtility.EnterColorScope(ConsoleColor.Red, null))
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Esempio n. 7
0
        static int Main(string[] args)
        {
            MixerParameters parameters;
            CommandLineClassParser <MixerParameters> parser = new CommandLineClassParser <MixerParameters> ();

            try
            {
                parameters = parser.Parse(args);
            }
            catch (CommandLineArgumentException e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.WriteLine("Usage:");
                System.Console.WriteLine(parser.GetAsciiSynopsis(Environment.GetCommandLineArgs()[0], System.Console.BufferWidth));
                return(1);
            }

            try
            {
                MixerRunner mixerRunner = new MixerRunner(parameters);
                mixerRunner.Run();
            }
            catch (Exception e)
            {
                using (ConsoleUtility.EnterColorScope(ConsoleColor.White, ConsoleColor.DarkRed))
                {
                    System.Console.Error.WriteLine("Execution aborted. Exception stack:");
                    for (; e != null; e = e.InnerException)
                    {
                        System.Console.Error.WriteLine("{0}: {1}\n{2}", e.GetType().FullName, e.Message, e.StackTrace);
                    }
                }
                return(1);
            }
            return(0);
        }