예제 #1
0
 public StringFormatRule(string rootType, string property, Func<string> formatDescription, Func<Regex> formatExpression, Func<string> reformatExpression = null, RuleInvocationType invocationTypes = RuleInvocationType.PropertyChanged)
     : base(rootType, property, CreateError(property, formatDescription), invocationTypes, property)
 {
     this.formatDescription = formatDescription;
     this.formatExpression = formatExpression;
     this.reformatExpression = reformatExpression;
 }
예제 #2
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, Error error)
     : base(rootType, property, error, invocationTypes)
 {
     this.CompareSource = compareSource;
     this.CompareOperator = compareOperator;
     this.CompareValue = compareValue;
     InitializePredicates(compareSource);
 }
예제 #3
0
파일: CompareRule.cs 프로젝트: vc3/ExoRule
 /// <summary>
 /// Creates a new instance of <see cref="CompareRule"/> for the specified property.
 /// </summary>
 /// <param name="rootType"></param>
 /// <param name="property"></param>
 /// <param name="conditionType"></param>
 /// <param name="comparePath"></param>
 /// <param name="compareOperator"></param>
 /// <param name="error"></param>
 /// <param name="invocationTypes"></param>
 public CompareRule(string rootType, string property, string compareSource, CompareOperator compareOperator, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes)
 {
     this.CompareSource = compareSource;
     this.CompareOperator = compareOperator;
     InitializePredicates(compareSource);
     ValidateRuleCriteria();
 }
예제 #4
0
        public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, params ConditionTypeSet[] sets)
            : base(rootType, property,
				CreateError(property, compareSource, compareOperator, compareValue, sets), invocationTypes)
        {
            this.CompareSource = compareSource;
            this.CompareOperator = compareOperator;
            this.CompareValue = compareValue;
            InitializePredicates(compareSource);
        }
예제 #5
0
        /// <summary>
        /// Creates a new rule instance.
        /// </summary>
        /// <param name="rootType">The root <see cref="ModelType"/> the rule is for</param>
        /// <param name="name"></param>
        /// <param name="invocationTypes"></param>
        /// <param name="predicates"></param>
        public Rule(string rootType, string name, RuleInvocationType invocationTypes, ConditionType[] conditionTypes, params string[] predicates)
        {
            this.rootTypeName    = rootType;
            this.Name            = name;
            this.InvocationTypes = invocationTypes;
            this.ConditionTypes  = conditionTypes ?? new ConditionType[0];

            // Default the execution location to server
            this.ExecutionLocation = RuleExecutionLocation.Server;

            // Split the predicates into property change paths and return values
            if (predicates != null && predicates.Length > 0)
            {
                SetPredicates(predicates);
            }
        }
예제 #6
0
파일: PropertyRule.cs 프로젝트: vc3/ExoRule
        /// <summary>
        /// Creates a new <see cref="PropertyRule"/> for the specified property and condition type.
        /// </summary>
        /// <param name="rootType"></param>
        /// <param name="property"></param>
        /// <param name="conditionType"></param>
        /// <param name="invocationTypes"></param>
        /// <param name="predicates"></param>
        public PropertyRule(string rootType, string property, Func<ModelType, ConditionType> conditionType, RuleInvocationType invocationTypes, params string[] predicates)
            : base(rootType, rootType + "." + property, invocationTypes, predicates)
        {
            this.property = property;
            this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;

            if (conditionType != null)
            Initialize += (s, e) =>
            {
                // Make sure the condition type and rule have a unique name
                var type = RootType;
                var error = conditionType(type);
                var originalCode = error.Code;
                var uniqueCode = originalCode;
                int count = 1;
                while (ConditionType.GetConditionTypes(type).Any(ct => ct.Code == uniqueCode))
                    uniqueCode = originalCode + count++;
                error.Code = uniqueCode;
                Name = uniqueCode;

                // Assign the condition type to the rule
                ConditionTypes = new ConditionType[] { error };
            };
        }
예제 #7
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, object requiredValue, params ConditionTypeSet[] sets)
     : this(rootType, property, compareSource, compareOperator, compareValue, invocationTypes, sets)
 {
     RequiredValue = requiredValue;
 }
예제 #8
0
 public ListLengthRule(string rootType, string property, int minimum, int maximum, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes, property)
 {
     this.Minimum = minimum;
     this.Maximum = maximum;
 }
예제 #9
0
 public AllowedValuesRule(string rootType, string property, LambdaExpression source, Error error, RuleInvocationType invocationTypes, bool ignoreValidation = false)
     : base(rootType, property, error, invocationTypes)
 {
     this.IgnoreValidation = ignoreValidation;
     InitializeSource(null, source);
 }
예제 #10
0
 public StringFormatRule(string rootType, string property, Error error, Func <Regex> formatExpression, Func <string> reformatExpression = null, RuleInvocationType invocationTypes = RuleInvocationType.PropertyChanged)
     : base(rootType, property, error, invocationTypes, property)
 {
     this.formatExpression   = formatExpression;
     this.reformatExpression = reformatExpression;
 }
예제 #11
0
 public ListLengthRule(string rootType, string property, int minimum, int maximum, RuleInvocationType invocationTypes)
     : base(rootType, property, CreateError(property, minimum, maximum), invocationTypes, property)
 {
     this.Minimum = minimum;
     this.Maximum = maximum;
 }
예제 #12
0
파일: RequiredRule.cs 프로젝트: vc3/ExoRule
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, Error error)
     : base(rootType, property, error, invocationTypes, property)
 {
 }
예제 #13
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, object requiredValue, params ConditionTypeSet[] sets)
     : this(rootType, property, compareSource, compareOperator, compareValue, invocationTypes, sets)
 {
     RequiredValue = requiredValue;
 }
예제 #14
0
파일: OwnerRule.cs 프로젝트: vc3/ExoRule
 public OwnerRule(string rootType, string property, RuleInvocationType invocationTypes)
     : base(rootType, property, (Func<ModelType, ConditionType>)null, invocationTypes, property)
 {
 }
예제 #15
0
파일: PropertyRule.cs 프로젝트: vc3/ExoRule
 protected PropertyRule(string rootType, string property, RuleInvocationType invocationTypes, params string[] predicates)
     : base(rootType, property, predicates)
 {
     this.property = property;
     this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;
 }
예제 #16
0
파일: PropertyRule.cs 프로젝트: vc3/ExoRule
 /// <summary>
 /// Creates a new <see cref="PropertyRule"/> for the specified property and condition type.
 /// </summary>
 /// <param name="rootType"></param>
 /// <param name="property"></param>
 /// <param name="conditionType"></param>
 /// <param name="invocationTypes"></param>
 /// <param name="predicates"></param>
 public PropertyRule(string rootType, string property, ConditionType conditionType, RuleInvocationType invocationTypes, params string[] predicates)
     : base(rootType, conditionType.Code, invocationTypes, new ConditionType[] { conditionType }, predicates)
 {
     this.property = property;
     this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;
 }
예제 #17
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, Error error, object requiredValue)
     : this(rootType, property, compareSource, compareOperator, compareValue, invocationTypes, error)
 {
     RequiredValue = requiredValue;
 }
예제 #18
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, Error error)
     : base(rootType, property, error, invocationTypes)
 {
     this.CompareSource   = compareSource;
     this.CompareOperator = compareOperator;
     this.CompareValue    = compareValue;
     InitializePredicates(compareSource);
 }
예제 #19
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, Error error, object requiredValue)
     : this(rootType, property, compareSource, compareOperator, compareValue, invocationTypes, error)
 {
     RequiredValue = requiredValue;
 }
예제 #20
0
 public OwnerRule(string rootType, string property, RuleInvocationType invocationTypes)
     : base(rootType, property, (Func <ModelType, ConditionType>)null, invocationTypes, property)
 {
 }
예제 #21
0
 /// <summary>
 /// Creates a new rule instance.
 /// </summary>
 /// <param name="rootType">The root <see cref="ModelType"/> the rule is for</param>
 /// <param name="name"></param>
 /// <param name="invocationTypes"></param>
 /// <param name="predicates"></param>
 public Rule(string rootType, string name, RuleInvocationType invocationTypes, params string[] predicates)
     : this(rootType, name, invocationTypes, null, predicates)
 {
 }
예제 #22
0
 protected PropertyRule(string rootType, string property, RuleInvocationType invocationTypes, params string[] predicates)
     : base(rootType, property, predicates)
 {
     this.property          = property;
     this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;
 }
예제 #23
0
파일: RequiredRule.cs 프로젝트: vc3/ExoRule
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, string errorMessage, object requiredValue, params ConditionTypeSet[] sets)
     : this(rootType, property, invocationTypes, new Error(GetErrorCode(rootType, property, "Required"), errorMessage, sets))
 {
     RequiredValue = requiredValue;
 }
예제 #24
0
 /// <summary>
 /// Creates a new <see cref="PropertyRule"/> for the specified property and condition type.
 /// </summary>
 /// <param name="rootType"></param>
 /// <param name="property"></param>
 /// <param name="conditionType"></param>
 /// <param name="invocationTypes"></param>
 /// <param name="predicates"></param>
 public PropertyRule(string rootType, string property, ConditionType conditionType, RuleInvocationType invocationTypes, params string[] predicates)
     : base(rootType, conditionType.Code, invocationTypes, new ConditionType[] { conditionType }, predicates)
 {
     this.property          = property;
     this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;
 }
예제 #25
0
파일: RequiredRule.cs 프로젝트: vc3/ExoRule
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, Error error, object requiredValue)
     : base(rootType, property, error, invocationTypes, property)
 {
     RequiredValue = requiredValue;
 }
예제 #26
0
        /// <summary>
        /// Creates a new <see cref="PropertyRule"/> for the specified property and condition type.
        /// </summary>
        /// <param name="rootType"></param>
        /// <param name="property"></param>
        /// <param name="conditionType"></param>
        /// <param name="invocationTypes"></param>
        /// <param name="predicates"></param>
        public PropertyRule(string rootType, string property, Func <ModelType, ConditionType> conditionType, RuleInvocationType invocationTypes, params string[] predicates)
            : base(rootType, rootType + "." + property, invocationTypes, predicates)
        {
            this.property          = property;
            this.ExecutionLocation = RuleExecutionLocation.ServerAndClient;

            if (conditionType != null)
            {
                Initialize += (s, e) =>
                {
                    // Make sure the condition type and rule have a unique name
                    var type         = RootType;
                    var error        = conditionType(type);
                    var originalCode = error.Code;
                    var uniqueCode   = originalCode;
                    int count        = 1;
                    while (ConditionType.GetConditionTypes(type).Any(ct => ct.Code == uniqueCode))
                    {
                        uniqueCode = originalCode + count++;
                    }
                    error.Code = uniqueCode;
                    Name       = uniqueCode;

                    // Assign the condition type to the rule
                    ConditionTypes = new ConditionType[] { error };
                }
            }
            ;
        }
예제 #27
0
 public ListLengthRule(string rootType, string property, int minimum, int maximum, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes, property)
 {
     this.Minimum = minimum;
     this.Maximum = maximum;
 }
예제 #28
0
 /// <summary>
 /// Creates a new instance of <see cref="CompareRule"/> for the specified property.
 /// </summary>
 /// <param name="rootType"></param>
 /// <param name="property"></param>
 /// <param name="conditionType"></param>
 /// <param name="comparePath"></param>
 /// <param name="compareOperator"></param>
 /// <param name="error"></param>
 /// <param name="invocationTypes"></param>
 public CompareRule(string rootType, string property, string compareSource, CompareOperator compareOperator, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes)
 {
     this.CompareSource   = compareSource;
     this.CompareOperator = compareOperator;
     InitializePredicates(compareSource);
     ValidateRuleCriteria();
 }
예제 #29
0
 public AllowedValuesRule(string rootType, string property, string source, RuleInvocationType invocationTypes, bool ignoreValidation = false)
     : base(rootType, property, CreateError(property), invocationTypes)
 {
     this.IgnoreValidation = ignoreValidation;
     InitializeSource(source, null);
 }
예제 #30
0
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, object requiredValue, params ConditionTypeSet[] sets)
     : base(rootType, property, CreateError(property, sets), invocationTypes, property)
 {
     RequiredValue = requiredValue;
 }
예제 #31
0
 public ListLengthRule(string rootType, string property, int minimum, int maximum, RuleInvocationType invocationTypes)
     : base(rootType, property, CreateError(property, minimum, maximum), invocationTypes, property)
 {
     this.Minimum = minimum;
     this.Maximum = maximum;
 }
예제 #32
0
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, string errorMessage, object requiredValue, params ConditionTypeSet[] sets)
     : this(rootType, property, invocationTypes, new Error(GetErrorCode(rootType, property, "Required"), errorMessage, sets))
 {
     RequiredValue = requiredValue;
 }
예제 #33
0
 public AllowedValuesRule(string rootType, string property, LambdaExpression source, Error error, RuleInvocationType invocationTypes, bool ignoreValidation = false)
     : base(rootType, property, error, invocationTypes)
 {
     this.IgnoreValidation = ignoreValidation;
     InitializeSource(null, source);
 }
예제 #34
0
 public RangeRule(string rootType, string property, IComparable minimum, IComparable maximum, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes, property)
 {
     SetRange(minimum, maximum);
 }
예제 #35
0
 public AllowedValuesRule(string rootType, string property, string source, RuleInvocationType invocationTypes, bool ignoreValidation = false)
     : base(rootType, property, CreateError(property), invocationTypes)
 {
     this.IgnoreValidation = ignoreValidation;
     InitializeSource(source, null);
 }
예제 #36
0
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, Error error, object requiredValue)
     : base(rootType, property, error, invocationTypes, property)
 {
     RequiredValue = requiredValue;
 }
예제 #37
0
파일: RangeRule.cs 프로젝트: vc3/ExoRule
 public RangeRule(string rootType, string property, IComparable minimum, IComparable maximum, Error error, RuleInvocationType invocationTypes)
     : base(rootType, property, error, invocationTypes, property)
 {
     SetRange(minimum, maximum);
 }
예제 #38
0
파일: RequiredRule.cs 프로젝트: vc3/ExoRule
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, object requiredValue, params ConditionTypeSet[] sets)
     : base(rootType, property, CreateError(property, sets), invocationTypes, property)
 {
     RequiredValue = requiredValue;
 }
예제 #39
0
 public RequiredRule(string rootType, string property, RuleInvocationType invocationTypes, Error error)
     : base(rootType, property, error, invocationTypes, property)
 {
 }
예제 #40
0
 public RequiredIfRule(string rootType, string property, string compareSource, CompareOperator compareOperator, object compareValue, RuleInvocationType invocationTypes, params ConditionTypeSet[] sets)
     : base(rootType, property,
            CreateError(property, compareSource, compareOperator, compareValue, sets), invocationTypes)
 {
     this.CompareSource   = compareSource;
     this.CompareOperator = compareOperator;
     this.CompareValue    = compareValue;
     InitializePredicates(compareSource);
 }