예제 #1
0
 public override bool IsMatch(PropertyConditionContext context)
 {
     if (context.PropertyValue == null) {
         return false;
     }
     return true;
 }
        public override bool IsMatch(PropertyConditionContext context)
        {
            var propertyValue = (IComparable)context.PropertyValue;

            // If the value is null then we abort and assume success.
            // This should not be a failure condition - only a NotNull/NotEmpty should cause a null to fail.
            if (propertyValue == null) return false;

            return IsValid(propertyValue, From, To);
        }
예제 #3
0
        public override bool IsMatch(PropertyConditionContext context)
        {
            if (context.PropertyValue == null
                || IsInvalidString(context.PropertyValue)
                || IsEmptyCollection(context.PropertyValue)
                || Equals(context.PropertyValue, defaultValueForType)) {
                return true;
            }

            return false;
        }
예제 #4
0
        public override bool IsMatch(PropertyConditionContext context)
        {
            var comparisonValue = GetComparisonValue(context);
            bool success = Compare(comparisonValue, context.PropertyValue);

            if (!success) {
                //context.MessageFormatter.AppendArgument("ComparisonValue", comparisonValue);
                return false;
            }

            return true;
        }
예제 #5
0
        public override bool IsMatch(PropertyConditionContext context)
        {
            if (context.PropertyValue == null) return false;

            int length = context.PropertyValue.ToString().Length;

            if (length < Min || (length > Max && Max != -1))
            {
                return false;
            }

            return true;
        }
예제 #6
0
        public override bool IsMatch(PropertyConditionContext context)
        {
            //var comparisonValue = GetComparisonValue(context);
            if (this.ValuesToCompare == null || !this.ValuesToCompare.Cast<object>().Any())
            {
                return true;
            }

            bool success = false;
            foreach (object comparisonValue in this.ValuesToCompare)
            {
                success = Compare(comparisonValue, context.PropertyValue);
                if (success == true)
                {
                    break;
                }
            }

            return !success;
        }
예제 #7
0
        public override bool IsMatch(PropertyConditionContext context)
        {
            //var comparisonValue = GetComparisonValue(context);
            if (this.ValuesToCompare == null || !this.ValuesToCompare.Any())
            {
                return false;
            }

            bool success = false;
            foreach (string comparisonValue in this.ValuesToCompare)
            {
                success = string.Equals(context.PropertyValue.ToString(), comparisonValue, this._comparison);
                if (success == true)
                {
                    break;
                }
            }

            return success;
        }
예제 #8
0
 public abstract bool IsMatch(PropertyConditionContext context);
예제 #9
0
        private object GetComparisonValue(PropertyConditionContext context)
        {
            if(_func != null) {
                return _func(context.Instance);
            }

            return ValueToCompare;
        }
예제 #10
0
 public bool IsMatch(PropertyConditionContext context)
 {
     return this._predicate(context.Instance);
 }
        public override sealed bool IsMatch(PropertyConditionContext context)
        {
            if (context.PropertyValue == null)
            {
                return false;
            }

            var value = GetComparisonValue(context);

            if (!IsValid((IComparable)context.PropertyValue, value))
            {
                return false;
            }

            return true;
        }
        private IComparable GetComparisonValue(PropertyConditionContext context)
        {
            if (_valueToCompareFunc != null)
            {
                return (IComparable)_valueToCompareFunc(context.Instance);
            }

            return (IComparable)ValueToCompare;
        }