Esempio n. 1
0
        public static MvcHtmlString ToHtmlString(ComparisonPredicate expression, bool link = true)
        {
            var comparator = "";
            if (expression.Criteria == ComparisonCriteria.Equals)
                comparator = "=";

            if (expression.Criteria == ComparisonCriteria.BiggerThan)
                comparator = ">";

            if (expression.Criteria == ComparisonCriteria.BiggerThanOrEquals)
                comparator = "≥";

            if (expression.Criteria == ComparisonCriteria.LessThan)
                comparator = "<";

            if (expression.Criteria == ComparisonCriteria.LessThanOrEquals)
                comparator = "&le;";

            if (expression.Criteria == ComparisonCriteria.NotEquals)
                comparator = "&ne;";

            return MvcHtmlString.Create (string.Format("{0} {1} {2}",
                                                       Embed(expression, expression.Left, expression.Left.ToHtmlString(link)),
                                                       comparator,
                                                       Embed(expression, expression.Right, expression.Right.ToHtmlString(link))
                                                       ));
        }
        private static string ToHtmlString(ComparisonPredicate expression)
        {
            var comparator = "";
            if (expression.Criteria == ComparisonCriteria.Equals)
                comparator = "=";

            if (expression.Criteria == ComparisonCriteria.BiggerThan)
                comparator = ">";

            if (expression.Criteria == ComparisonCriteria.BiggerThanOrEquals)
                comparator = "&ge;";

            if (expression.Criteria == ComparisonCriteria.LessThan)
                comparator = "<";

            if (expression.Criteria == ComparisonCriteria.LessThanOrEquals)
                comparator = "&le;";

            if (expression.Criteria == ComparisonCriteria.NotEquals)
                comparator = "&ne;";

            return string.Format ("{0} {1} {2}",
                                 Parenthesize (expression, expression.Left, ToHtmlString (expression.Left)),
                                 comparator,
                                 Parenthesize (expression, expression.Right, ToHtmlString (expression.Right))
                                 );
        }