private IEventProvider GetEventProvider()
 {
     if (_analysis.TimeRulePlugIn.Name == "Periodic")
     {
         return(new PeriodicEventProvider(_analysis.TimeRule));
     }
     else if (_analysis.TimeRulePlugIn.Name == "Natural")
     {
         return(new NatualEventProvider(_configuration.GetInputs().OfType <AFAttribute>()));
     }
     else
     {
         throw new InvalidOperationException("Invalid time rule...");
     }
 }
        private bool TryValidate()
        {
            if (_analysis.Status != AFStatus.Enabled)
            {
                Console.WriteLine("'{0}' is not enabled.", _analysis.GetPath());
                return(false);
            }

            _configuration = _analysis.AnalysisRule.GetConfiguration();
            if (_configuration.HasExceptions)
            {
                var exceptionGroups = _configuration.ConfigurationExceptions.ToLookup(ex => ex.Severity);
                Console.WriteLine("Configuration warnings: {0}", exceptionGroups[AFAnalysisErrorSeverity.Warning].Count());
                foreach (var warning in exceptionGroups[AFAnalysisErrorSeverity.Warning])
                {
                    Console.WriteLine("\t{0}", warning.Message);
                }

                // warnings mean ok to run, but something may not work quite as expected.
                int errorCount = exceptionGroups[AFAnalysisErrorSeverity.Error].Count();
                Console.WriteLine("Configuration errors: {0}", errorCount);
                foreach (var error in exceptionGroups[AFAnalysisErrorSeverity.Error])
                {
                    Console.WriteLine("\t{0}", error.Message);
                }

                // can't run if there are errors.
                if (errorCount > 0)
                {
                    return(false);
                }
            }

            var inputs  = _configuration.GetInputs();
            var outputs = _configuration.GetOutputs();

            foreach (var output in outputs)
            {
                if (inputs.Any(ip => ip.ID == output.ID))
                {
                    Console.WriteLine("This approach for evaluating analyses does not support using same attribute(s) as input as well output. ('{0}')", output.Name);
                    return(false);
                }
            }

            return(true);
        }