Esempio n. 1
0
        static Boolean VaryStart <T>(this IValueConverter <T> converter, CssValueList list, Func <IValueConverter <T>, ICssValue, Boolean> validate)
        {
            var min = Math.Max(converter.MinArgs, 1);
            var max = converter.MaxArgs;
            var n   = Math.Min(max, list.Length);

            for (int count = n; count >= min; count--)
            {
                var subset = count > 1 ? list.Subset(0, count) : list[0];

                if (validate(converter, subset))
                {
                    list.RemoveRange(0, count);
                    return(true);
                }
            }

            return(validate(converter, null));
        }
Esempio n. 2
0
        static Boolean VaryAll <T>(this IValueConverter <T> converter, CssValueList list, Func <IValueConverter <T>, ICssValue, Boolean> validate)
        {
            var min = Math.Max(converter.MinArgs, 1);
            var max = converter.MaxArgs;

            for (int i = 0; i < list.Length; i++)
            {
                var n = Math.Min(Math.Min(max, list.Length) + i, list.Length);

                for (int j = n; j >= i + min; j--)
                {
                    var count  = j - i;
                    var subset = count > 1 ? list.Subset(i, j) : list[i];

                    if (validate(converter, subset))
                    {
                        list.RemoveRange(i, count);
                        return(true);
                    }
                }
            }

            return(validate(converter, null));
        }