Exemplo n.º 1
0
 public static RuleSetValidationResult NewRuleSetValidationMessageResult(this RuleSet ruleSet, IObjectSpace objectSpace, string messageTemplate, ContextIdentifier contextIdentifier, object objectTarget, Type targeObjecttType) {
     var rule = new RuleMessage(contextIdentifier, targeObjecttType);
     rule.Properties.SkipNullOrEmptyValues = false;
     rule.Properties.CustomMessageTemplate = messageTemplate;
     Validator.RuleSet.RegisteredRules.Add(rule);
     RuleSetValidationResult validationResult;
     using (objectSpace.CreateParseCriteriaScope()) {
         validationResult = Validator.RuleSet.ValidateTarget(objectSpace, objectTarget, contextIdentifier);
     }
     Validator.RuleSet.RegisteredRules.Remove(rule);
     return validationResult;
 }
Exemplo n.º 2
0
        private bool?IsObjectFitForCriteria(IModelDatabaseMaintanance databaseMaintanance, IObjectSpace objectSpace)
        {
            var user = objectSpace.GetObject(SecuritySystem.CurrentUser);
            CriteriaOperator criteriaOperator;
            var typeInfo         = databaseMaintanance.UserModelClass?.TypeInfo;
            var targetObjectType = typeInfo?.Type;

            using (objectSpace.CreateParseCriteriaScope()){
                criteriaOperator = CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(databaseMaintanance.UserCriteria, targetObjectType);
            }

            var fit = objectSpace.GetExpressionEvaluator(new EvaluatorContextDescriptorDefault(typeInfo == null?typeof(object):targetObjectType), criteriaOperator).Fit(typeInfo == null?new object():user);

            return(fit);
        }
Exemplo n.º 3
0
        public static RuleSetValidationResult NewRuleSetValidationMessageResult(this RuleSet ruleSet, IObjectSpace objectSpace, string messageTemplate, ContextIdentifier contextIdentifier, object objectTarget, Type targeObjecttType)
        {
            var rule = new RuleMessage(contextIdentifier, targeObjecttType);

            rule.Properties.SkipNullOrEmptyValues = false;
            rule.Properties.CustomMessageTemplate = messageTemplate;
            Validator.RuleSet.RegisteredRules.Add(rule);
            RuleSetValidationResult validationResult;

            using (objectSpace.CreateParseCriteriaScope()) {
                validationResult = Validator.RuleSet.ValidateTarget(objectSpace, objectTarget, contextIdentifier);
            }
            Validator.RuleSet.RegisteredRules.Remove(rule);
            return(validationResult);
        }
Exemplo n.º 4
0
        private void SetupActiveFilterCriteriaToControl()
        {
            IObjectSpace objectSpace = _columnViewEditor.CollectionSource.ObjectSpace;
            ITypeInfo    typeInfo    = Model.ModelClass.TypeInfo;

            using (objectSpace.CreateParseCriteriaScope()){
                CriteriaOperator criteriaOperator = objectSpace.ParseCriteria(Model.Filter);
                if (_columnViewEditor.IsAsyncServerMode())
                {
                    new AsyncServerModeCriteriaProccessor(typeInfo).Process(criteriaOperator);
                }
                var criteriaProcessor = new FilterWithObjectsProcessor(objectSpace, typeInfo, _columnViewEditor.IsAsyncServerMode());
                criteriaProcessor.Process(criteriaOperator, FilterWithObjectsProcessorMode.StringToObject);
                var enumParametersProcessor = new EnumPropertyValueCriteriaProcessor(_columnViewEditor.CollectionSource.ObjectTypeInfo);
                enumParametersProcessor.Process(criteriaOperator);
                Control.ActiveFilterCriteria = criteriaOperator;
            }
        }