Beispiel #1
0
#pragma warning disable 1591 // Xml Comments
        public QueryValidationResult Validate(IQuery query)
        {
            var brokenRules = new Dictionary<IRule, BrokenRule>();

            var ruleContext = _ruleContexts.GetFor(query);
            ruleContext.OnFailed(RuleFailed(ruleContext, brokenRules));

            var hasDescriptor = _descriptors.CallGenericMethod<bool, IQueryValidationDescriptors>(d => d.HasDescriptorFor<IQuery>, query.GetType());
            if (hasDescriptor)
            {
                var descriptor = _descriptors.CallGenericMethod<IQueryValidationDescriptor, IQueryValidationDescriptors>(d => d.GetDescriptorFor<IQuery>, query.GetType());
                descriptor.ArgumentRules.ForEach(r => {
                    var value = r.Property.GetValue(query);
                    r.Evaluate(ruleContext, value);
                });
            }

            var result = new QueryValidationResult(brokenRules.Values);
            return result;
        }
Beispiel #2
0
#pragma warning disable 1591 // Xml Comments
        public QueryValidationResult Validate(IQuery query)
        {
            var brokenRules = new Dictionary <IRule, BrokenRule>();

            var ruleContext = _ruleContexts.GetFor(query);

            ruleContext.OnFailed(RuleFailed(ruleContext, brokenRules));

            var hasDescriptor = _descriptors.CallGenericMethod <bool, IQueryValidationDescriptors>(d => d.HasDescriptorFor <IQuery>, query.GetType());

            if (hasDescriptor)
            {
                var descriptor = _descriptors.CallGenericMethod <IQueryValidationDescriptor, IQueryValidationDescriptors>(d => d.GetDescriptorFor <IQuery>, query.GetType());
                descriptor.ArgumentRules.ForEach(r => {
                    var value = r.Property.GetValue(query);
                    r.Evaluate(ruleContext, value);
                });
            }

            var result = new QueryValidationResult(brokenRules.Values);

            return(result);
        }
Beispiel #3
0
 /// <summary>
 /// Initializes an instance of <see cref="QueryResult"/>
 /// </summary>
 public QueryResult()
 {
     SecurityMessages = new string[0];
     Validation = new QueryValidationResult(new BrokenRule[0]);
 }