コード例 #1
0
 /// <inheritdoc />
 protected ValueCompareBasicToken(VerifiableMemberContract contract, object valueToCompare, string tokenName) : base(contract)
 {
     _valueToCompare       = valueToCompare;
     _valueToCompareFunc   = null;
     _typeOfValueToCompare = _valueToCompare.GetType();
     TokenName             = tokenName;
 }
コード例 #2
0
 /// <inheritdoc />
 protected ValueCompareBasicToken(VerifiableMemberContract contract, Func <object> valueToCompareFunc, Type valueType, string tokenName) : base(contract)
 {
     _valueToCompare       = default;
     _valueToCompareFunc   = valueToCompareFunc;
     _typeOfValueToCompare = valueType;
     TokenName             = tokenName;
 }
コード例 #3
0
        /// <inheritdoc />
        public ValueRangeToken(VerifiableMemberContract contract, TVal from, TVal to, RangeOptions options) : base(contract)
        {
            _from = from;
            _to   = to;

            _options = options;
        }
コード例 #4
0
 /// <inheritdoc />
 public ValueMinLengthLimitedToken(VerifiableMemberContract contract, int min) : base(contract)
 {
     if (min < 0)
     {
         throw new ArgumentOutOfRangeException(nameof(min));
     }
     _minLength = min;
 }
コード例 #5
0
 /// <inheritdoc />
 public ValueMaxLengthLimitedToken(VerifiableMemberContract contract, int max) : base(contract)
 {
     if (max < 0)
     {
         throw new ArgumentOutOfRangeException(nameof(max));
     }
     _maxLength = max;
 }
コード例 #6
0
 public ValueValidationRegistrar(
     VerifiableMemberContract verifiableMemberContract,
     List <CorrectValueRule> rules,
     VerifyRuleMode mode,
     IFluentValidationRegistrar <T> parentRegistrar,
     IValidationRegistrar rootRegistrar)
     : base(verifiableMemberContract, rules, mode, parentRegistrar, rootRegistrar)
 {
     ValueRuleBuilder = new CorrectValueRuleBuilder <T, TVal>(verifiableMemberContract, mode);
 }
コード例 #7
0
        /// <inheritdoc />
        public ValueStringEnumToken(VerifiableMemberContract contract, Type enumType, bool caseSensitive) : base(contract)
        {
            _enumType      = enumType ?? throw new ArgumentNullException(nameof(enumType));
            _caseSensitive = caseSensitive;

            if (!enumType.IsEnum)
            {
                throw new ArgumentOutOfRangeException(nameof(enumType), $"The type '{enumType.Name}' is not an enum and can't be used with IsEnumName.");
            }
        }
コード例 #8
0
 public GroupedValueToken(VerifiableMemberContract contract, bool internalLogic = true)
 {
     _contract         = contract;
     WorkingList       = new List <IValueToken>();
     _correctValueRule = new LogicCorrectValueRule {
         Contract = contract, MemberName = MemberName, Mode = CorrectValueRuleMode.Append, Tokens = WorkingList
     };
     TokenName    = CreateName(_contract);
     Relationship = ConditionOps.Break;
     LogicFlag    = internalLogic;
 }
コード例 #9
0
 protected ValueRequiredBasicToken(
     VerifiableMemberContract contract,
     bool not,
     string tokenName,
     int[] mutuallyExclusiveFlags = null,
     bool?mutuallyExclusive       = null) : base(contract)
 {
     Not                    = not;
     TokenName              = tokenName;
     MutuallyExclusive      = mutuallyExclusive ?? mutuallyExclusiveFlags is not null;
     MutuallyExclusiveFlags = mutuallyExclusiveFlags ?? NoMutuallyExclusiveFlags;
 }
コード例 #10
0
 public ValueValidationRegistrar(
     VerifiableMemberContract verifiableMemberContract,
     List <CorrectValueRule> rules,
     VerifyRuleMode mode,
     IFluentValidationRegistrar parentRegistrar,
     IValidationRegistrar rootRegistrar)
 {
     _rootRegistrar            = rootRegistrar ?? throw new ArgumentNullException(nameof(rootRegistrar));
     _parentRegistrar          = parentRegistrar ?? throw new ArgumentNullException(nameof(parentRegistrar));
     _verifiableMemberContract = verifiableMemberContract ?? throw new ArgumentNullException(nameof(verifiableMemberContract));
     ValueRuleBuilder          = new CorrectValueRuleBuilder(verifiableMemberContract, mode);
     _parentRulesRef           = rules;
 }
コード例 #11
0
        /// <inheritdoc />
        public ValueLengthLimitedToken(VerifiableMemberContract contract, int min, int max) : base(contract)
        {
            if (min < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(min));
            }
            if (max != -1 && max < min)
            {
                throw new ArgumentOutOfRangeException(nameof(max), "Max should be larger than min.");
            }

            _minLength = min;
            _maxLength = max;
        }
コード例 #12
0
        public CorrectValueRuleNodeState(
            VerifiableMemberContract contract,
            IGroupedValueToken groupedToken,
            IValueToken currentTokenPtr,
            ConditionOps implicitNextOps = ConditionOps.Break
            )
        {
            _contract = contract;

            _rootNode        = groupedToken;
            _workingNode     = groupedToken;
            _currentTokenPtr = currentTokenPtr;

            _nextOps = implicitNextOps;
        }
コード例 #13
0
        public static bool BasicTypeState(this VerifiableMemberContract contract)
        {
            if (contract is null)
            {
                return(false);
            }

            switch (contract.MemberKind)
            {
            case VerifiableMemberKind.CustomContract:
                return(contract.ExposeInternalImpl().IsBasicType);

            case VerifiableMemberKind.Unknown:
            case VerifiableMemberKind.Field:
            case VerifiableMemberKind.Property:
                return(contract.IsBasicType);

            default:
                return(false);
            }
        }
コード例 #14
0
        /// <inheritdoc />
        public ValueRangeToken(VerifiableMemberContract contract, object from, object to, RangeOptions options) : base(contract)
        {
            if (from is null || to is null)
            {
                _from = default;
                _to   = default;
                _returnFalseDirectly = true;
            }

            if (!_returnFalseDirectly && from is IComparable from0)
            {
                _from = from0;
            }
            else
            {
                _from = default;
                _returnFalseDirectly = true;
            }

            if (!_returnFalseDirectly && to is IComparable to0)
            {
                _to = to0;
            }
            else
            {
                _to = default;
                _returnFalseDirectly = true;
            }

            if (!_returnFalseDirectly && _from !.CompareTo(_to) > 0)
            {
                _returnFalseDirectly = true;
            }

            _options = options;
        }
コード例 #15
0
 /// <inheritdoc />
 public ValueRegularExpressionToken(VerifiableMemberContract contract, Func <T, string> expressionFunc, RegexOptions options) : base(contract)
 {
     _regexFunc = x => CreateRegex(expressionFunc(x), options);
 }
コード例 #16
0
 /// <inheritdoc />
 public ValueRegularExpressionToken(VerifiableMemberContract contract, Func <T, Regex> regexFunc) : base(contract)
 {
     _regexFunc = regexFunc;
 }
コード例 #17
0
 /// <inheritdoc />
 public ValueRegularExpressionToken(VerifiableMemberContract contract, Regex regex) : base(contract)
 {
     _regexFunc = x => regex;
 }
コード例 #18
0
 /// <inheritdoc />
 public ValueRegularExpressionToken(VerifiableMemberContract contract, string expression) : base(contract)
 {
     _regexFunc = x => CreateRegex(expression);
 }
コード例 #19
0
 /// <inheritdoc />
 public ValueEnumToken(VerifiableMemberContract contract, Type enumType) : base(contract)
 {
     _enumType = enumType ?? throw new ArgumentNullException(nameof(enumType));
 }
コード例 #20
0
 protected ValueRequiredTypeToken(VerifiableMemberContract contract, Type type, bool not, string tokenName, int[] mutuallyExclusiveFlags = null, bool?mutuallyExclusive = null)
     : base(contract, not, tokenName, mutuallyExclusiveFlags, mutuallyExclusive)
 {
     _type = type ?? throw new ArgumentNullException(nameof(type));
 }
コード例 #21
0
 private VerifyMemberRulePackage()
 {
     DeclaringType = typeof(object);
     _contract     = default;
     _rule         = default;
 }
コード例 #22
0
 /// <inheritdoc />
 public ValueAllToken(VerifiableMemberContract contract, Func <object, bool> func) : base(contract, func, Name)
 {
 }
コード例 #23
0
 /// <inheritdoc />
 public ValueInToken(VerifiableMemberContract contract, ICollection <object> objects) : base(contract)
 {
     _objects     = objects ?? Arrays.Empty <object>();
     _objectsFunc = null;
 }
コード例 #24
0
 internal VerifyMemberRulePackage(Type declaringType, VerifiableMemberContract contract, CorrectValueRule rule)
 {
     DeclaringType = declaringType ?? throw new ArgumentNullException(nameof(declaringType));
     _contract     = contract ?? throw new ArgumentNullException(nameof(contract));
     _rule         = rule ?? throw new ArgumentNullException(nameof(rule));
 }
コード例 #25
0
 /// <inheritdoc />
 public ValueRequiredTypesToken(VerifiableMemberContract contract, params Type[] types)  : base(contract, false, Name)
 {
     _types = types;
 }
コード例 #26
0
 /// <inheritdoc />
 public ValueRequiredTypeToken(VerifiableMemberContract contract, Type type)
     : base(contract, false, Name, null, true)
 {
     _type = type ?? throw new ArgumentNullException(nameof(type));
 }
コード例 #27
0
 /// <inheritdoc />
 public ValueRequiredStringToken(VerifiableMemberContract contract)
     : base(contract, TypeClass.StringClazz, false, Name, null, true)
 {
 }
コード例 #28
0
 /// <inheritdoc />
 public ValueFuncToken(VerifiableMemberContract contract, Func <object, CustomVerifyResult> func) : base(contract)
 {
     _func = func;
 }
コード例 #29
0
 /// <inheritdoc />
 public ValueInToken(VerifiableMemberContract contract, Func <ICollection <object> > objectsFunc) : base(contract)
 {
     _objects     = default;
     _objectsFunc = objectsFunc;
 }
コード例 #30
0
 /// <inheritdoc />
 public ValueScalePrecisionToken(VerifiableMemberContract contract, int scale, int precision, bool ignoreTrailingZeros = false) : base(contract)
 {
     Init(scale, precision);
     IgnoreTrailingZeros = ignoreTrailingZeros;
 }