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);
        }
Beispiel #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;
        }
Beispiel #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;
        }
        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;
        }
Beispiel #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;
        }
        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;
        }
 public abstract bool IsMatch(PropertyConditionContext context);
Beispiel #9
0
        private object GetComparisonValue(PropertyConditionContext context)
        {
            if(_func != null) {
                return _func(context.Instance);
            }

            return ValueToCompare;
        }
 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;
        }