/// <summary> /// Validates all required dependency properties. /// </summary> /// <remarks> /// This method validates all properties that are marked as required dependency. /// </remarks> /// <param name="source"> /// The source setting. /// </param> /// <param name="others"> /// The list of other settings. /// </param> /// <param name="overall"> /// The list of overall dependency settings. /// </param> /// <exception cref="DependentViolationException"> /// This exception is thrown in case of a dependency violation takes place. /// </exception> private void ValidateRequiredDependencies(ArgumentProcessorSetting source, IEnumerable <ArgumentProcessorSetting> others, IEnumerable <ArgumentProcessorSetting> overall) { if (overall.Count() != others.Count()) { throw new DependentViolationException($"Parameter \"{source.ToParameterLabel()}\" requires {String.Join(" and ", overall.Select(x => $"\"{x.ToParameterLabel()}\""))}."); } }
/// <summary> /// Validates all optional dependency properties. /// </summary> /// <remarks> /// This method validates all properties that are marked as optional dependency. /// </remarks> /// <param name="source"> /// The source setting. /// </param> /// <param name="others"> /// The list of other settings. /// </param> /// <param name="overall"> /// The list of overall dependency settings. /// </param> /// <exception cref="DependentViolationException"> /// This exception is thrown in case of a dependency violation takes place. /// </exception> private void ValidateOptionalDependencies(ArgumentProcessorSetting source, IEnumerable <ArgumentProcessorSetting> others, IEnumerable <ArgumentProcessorSetting> overall) { if (overall.Any() && !others.Any()) { throw new DependentViolationException($"Parameter \"{source.ToParameterLabel()}\" depends on {String.Join(" or ", overall.Select(x => $"\"{x.ToParameterLabel()}\""))}."); } }