/// <summary> /// Gets the parameters information for the given operation /// </summary> /// <param name="operationName"></param> /// <param name="contractOperations"></param> /// <returns></returns> private ParameterDetailsInfo GetParameterInfo(string operationName, IEnumerable <OperationDescription> contractOperations) { var parameterInfo = new ParameterDetailsInfo(); var parameters = GetParameters(contractOperations.Single(x => x.Name == operationName)); foreach (var parameter in parameters.OrderBy(x => x.Position)) { var skipNullCheck = false; foreach (var customAttribute in parameter.GetCustomAttributes(inherit: false)) { if (customAttribute is AllowNullAttribute) { skipNullCheck = true; } } parameterInfo.ParameterDetails.Add(new ParameterDetails { Name = parameter.Name, Position = parameter.Position, SkipNullcheck = skipNullCheck }); } return(parameterInfo); }
/// <summary> /// Initializes a new instance of the <see cref="ValidatingParameterInspector"/> class. /// </summary> /// <param name="validators">The validators.</param> /// <param name="errorMessageGenerator">The error message generator.</param> /// <param name="validationResultsLogger">[Optional] The validation results logger</param> /// <param name="parameterDetailsInfo">The parameter info object for the optional validator skipping.</param> public ValidatingParameterInspector(IEnumerable <IObjectValidator> validators, IErrorMessageGenerator errorMessageGenerator, IValidationResultsLogger validationResultsLogger = null, ParameterDetailsInfo parameterDetailsInfo = null) { _validationResultsLogger = validationResultsLogger; if (validators == null) { throw new ArgumentNullException(nameof(validators)); } if (!validators.Any()) { throw new ArgumentException("At least one validator is required."); } if (errorMessageGenerator == null) { throw new ArgumentNullException(nameof(errorMessageGenerator)); } _validators = validators; _errorMessageGenerator = errorMessageGenerator; _parameterDetailsInfo = parameterDetailsInfo; }