コード例 #1
0
ファイル: QueryValidator.cs プロジェクト: LenFon/Bifrost
#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;
        }
コード例 #2
0
ファイル: QueryValidator.cs プロジェクト: csuffyy/Bifrost
#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);
        }
コード例 #3
0
ファイル: QueryResult.cs プロジェクト: LenFon/Bifrost
 /// <summary>
 /// Initializes an instance of <see cref="QueryResult"/>
 /// </summary>
 public QueryResult()
 {
     SecurityMessages = new string[0];
     Validation = new QueryValidationResult(new BrokenRule[0]);
 }