ValidateObject() публичный статический Метод

public static ValidateObject ( Type, propertyType, Comparison, comparison, StringComparison? @case ) : void
propertyType Type,
comparison Comparison,
@case StringComparison?
Результат void
Пример #1
0
    public static Expression <Func <T, bool> > BuildPredicate(string path, Comparison comparison, string[] values, StringComparison?stringComparison = null)
    {
        var propertyFunc = GetPropertyFunc(path);

        if (propertyFunc.Type == typeof(string))
        {
            WhereValidator.ValidateString(comparison, stringComparison);
            if (comparison == Comparison.In)
            {
                return(BuildStringIn(values, propertyFunc, stringComparison));
            }
            else
            {
                var value = values?.Single();
                return(BuildStringCompare(comparison, value, propertyFunc, stringComparison));
            }
        }
        else
        {
            WhereValidator.ValidateObject(propertyFunc.Type, comparison, stringComparison);
            if (comparison == Comparison.In)
            {
                return(BuildObjectIn(values, propertyFunc));
            }
            else
            {
                var value = values?.Single();
                return(BuildObjectCompare(comparison, value, propertyFunc));
            }
        }
    }
Пример #2
0
    public static Func <T, bool> BuildPredicate(string path, Comparison comparison, string[] values, StringComparison?stringComparison = null)
    {
        var propertyFunc = GetPropertyFunc(path);

        if (propertyFunc.Type == typeof(string))
        {
            WhereValidator.ValidateString(comparison, stringComparison);
            var stringComparisonValue = stringComparison.GetValueOrDefault(StringComparison.OrdinalIgnoreCase);
            if (comparison == Comparison.In)
            {
                return(BuildStringIn(propertyFunc, values, stringComparisonValue));
            }
            else
            {
                var value = values?.Single();
                return(target => BuildStringCompare(comparison, value, propertyFunc, target, stringComparisonValue));
            }
        }
        else
        {
            WhereValidator.ValidateObject(propertyFunc.Type, comparison, stringComparison);
            if (comparison == Comparison.In)
            {
                return(BuildObjectIn(propertyFunc, values));
            }
            else
            {
                var value = values?.Single();
                return(target => BuildObjectCompare(comparison, value, propertyFunc, target));
            }
        }
    }
Пример #3
0
    public static Func <TInput, bool> BuildPredicate(string path, Comparison comparison, string[] values, StringComparison?stringComparison = null)
    {
        var propertyFunc = PropertyCache <TInput> .GetProperty(path);

        if (propertyFunc.PropertyType == typeof(string))
        {
            WhereValidator.ValidateString(comparison, stringComparison);
            var stringComparisonValue = stringComparison.GetValueOrDefault(StringComparison.OrdinalIgnoreCase);
            switch (comparison)
            {
            case Comparison.In:
                return(BuildStringIn(propertyFunc, values, stringComparisonValue));

            case Comparison.NotIn:
                return(BuildStringIn(propertyFunc, values, stringComparisonValue, true));

            default:
                var value = values?.Single();
                return(target => BuildStringCompare(comparison, value, propertyFunc, target, stringComparisonValue));
            }
        }
        else
        {
            WhereValidator.ValidateObject(propertyFunc.PropertyType, comparison, stringComparison);
            switch (comparison)
            {
            case Comparison.In:
                return(BuildObjectIn(propertyFunc, values));

            case Comparison.NotIn:
                return(BuildObjectIn(propertyFunc, values, true));

            default:
                var value = values?.Single();
                return(target => BuildObjectCompare(comparison, value, propertyFunc, target));
            }
        }
    }
        internal static Expression <Func <T, bool> > BuildPredicate(string path, Comparison comparison, string[] values, StringComparison?stringComparison = null)
        {
            var property = PropertyCache <T> .GetProperty(path);

            if (property.PropertyType == typeof(string))
            {
                WhereValidator.ValidateString(comparison, stringComparison);
                switch (comparison)
                {
                case Comparison.In:
                    return(BuildStringIn(values, property, stringComparison));

                case Comparison.NotIn:
                    return(BuildStringIn(values, property, stringComparison, true));

                default:
                    var value = values?.Single();
                    return(BuildStringCompare(comparison, value, property, stringComparison));
                }
            }
            else
            {
                WhereValidator.ValidateObject(property.PropertyType, comparison, stringComparison);
                switch (comparison)
                {
                case Comparison.In:
                    return(BuildObjectIn(values, property));

                case Comparison.NotIn:
                    return(BuildObjectIn(values, property, true));

                default:
                    var value = values?.Single();
                    return(BuildObjectCompare(comparison, value, property));
                }
            }
        }