public override async Task<DependencyCheckStatus> GetStatus() { if (!this.Dependencies.Any()) return new DependencyCheckStatus(NAMEStatusLevel.Warn, message: "A OneOf condition dependency must have child dependencies."); try { var allDependenciesTasks = this.Dependencies.Select(d => d.GetStatus()); var results = await Task.WhenAll(allDependenciesTasks).ConfigureAwait(false); var bestStatus = results.Min(s => s.CheckStatus); string message = "Everything is ok!"; Exception innerException = null; if (bestStatus != NAMEStatusLevel.Ok) { message = string.Join(Environment.NewLine, results.Select(s => s.Message)); var exceptions = results.Where(s => s.InnerException != null).Select(s => s.InnerException); if (exceptions == null || exceptions.Count() == 0) innerException = new NAMEException("None of the dependencies matched the version", NAMEStatusLevel.Error); else innerException = new AggregateException(exceptions); } return new DependencyCheckStatus(bestStatus, message: message, innerException: innerException); } catch (NAMEException ex) { return new DependencyCheckStatus(ex.StatusLevel, message: ex.Message, innerException: ex); } }
public override async Task <DependencyCheckStatus> GetStatus() { if (!this.Dependencies.Any()) { return(new DependencyCheckStatus(false, message: "A OneOf condition dependency must have child dependencies.")); } try { var allDependenciesTasks = this.Dependencies.Select(d => d.GetStatus()); var results = await Task.WhenAll(allDependenciesTasks).ConfigureAwait(false); bool checkPassed = results.All(s => s.CheckPassed); string message = "Everything is ok!"; Exception innerException = null; if (!checkPassed) { message = string.Join(Environment.NewLine, results.Select(s => s.Message)); var exceptions = results.Where(s => s.InnerException != null).Select(s => s.InnerException); if (exceptions == null || exceptions.Count() == 0) { innerException = new NAMEException("None of the dependencies matched the version"); } else { innerException = new AggregateException(exceptions); } } return(new DependencyCheckStatus(checkPassed, message: message, innerException: innerException)); } catch (NAMEException ex) { return(new DependencyCheckStatus(false, message: ex.Message, innerException: ex)); } }