public IValidationResult Validate(IExcelLoader excelLoader, IDictionary<string, object> context)
        {
            if (excelLoader == null) throw new ArgumentNullException("excelLoader");

            var messages = new List<IValidationMessage>();
            var result = new ValidationResult {ValidationTarget = excelLoader, Messages = messages };
            var contextDic = context ?? new Dictionary<string, object>();

            try
            {
                foreach (var ruleResult in _rules.Select(r => r.Check(excelLoader, contextDic)))
                {
                    messages.AddRange(ruleResult.Messages);
                    if (_earlyExit && !ruleResult.ShouldContinue)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                var error = e.ToString().ToValidationError();
                messages.Add(error);
            }

            return result;
        }
        public IValidationResult Validate(IExcelParser excelParser)
        {
            if (excelParser == null) throw new ArgumentNullException("excelParser");

            var result = new ValidationResult {ValidationTarget = excelParser};

            try
            {
                foreach (var ruleResult in _rules.Select(r => r.Check(excelParser)))
                {
                    result.Messages.Add(ruleResult.Message);
                    if (!ruleResult.ShouldContinue)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                var error = e.ToString().ToValidationError();
                result.Messages.Add(error);
            }

            return result;
        }
        public IValidationResult Validate(IExcelLoader excelLoader, IDictionary<string, object> context)
        {
            if (excelLoader == null) throw new ArgumentNullException("excelLoader");

            var messages = new ConcurrentBag<IValidationMessage>();
            var result = new ValidationResult {ValidationTarget = excelLoader, Messages = messages };
            var contextDic = context ?? new Dictionary<string, object>();

            try
            {
                using (var cts = new CancellationTokenSource())
                {
                    _rules.AsParallel()
                          .WithCancellation(cts.Token)
                          .ForAll(r =>
                          {
                              var ruleResult = r.Check(excelLoader, contextDic);
                              foreach (var msg in ruleResult.Messages)
                              {
                                  messages.Add(msg);
                              }
                              if (_earlyExit && !ruleResult.ShouldContinue)
                              {
                                  cts.Cancel();
                              }
                          });
                }
            }
            catch (AggregateException ex)
            {
                var errors = ex.Flatten()
                               .InnerExceptions
                               .Select(x => x.ToString().ToValidationError());
                foreach (var error in errors)
                {
                    messages.Add(error);
                }
            }
            catch (OperationCanceledException)
            {
                // Intentionally swallow this exception.
            }

            catch (Exception ex)
            {
                var error = ex.ToString().ToValidationError();
                messages.Add(error);
            }

            return result;
        }