Пример #1
0
        public static HelperResult Print(object value, int depth = DefaultRecursionLimit, int enumerationLength = DefaultEnumerationLimit) {
            if (depth < 0) {
                throw new ArgumentOutOfRangeException(
                    "depth",
                    String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, 0));
            }
            if (enumerationLength <= 0) {
                throw new ArgumentOutOfRangeException(
                    "enumerationLength",
                    String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThan, 0));
            }

            HtmlObjectPrinter printer = new HtmlObjectPrinter(depth, enumerationLength);
            return new HelperResult(writer => printer.WriteTo(value, writer));
        }
Пример #2
0
        public static HelperResult Print(object value, int depth = DefaultRecursionLimit, int enumerationLength = DefaultEnumerationLimit)
        {
            if (depth < 0)
            {
                throw new ArgumentOutOfRangeException(
                          "depth",
                          String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, 0));
            }
            if (enumerationLength <= 0)
            {
                throw new ArgumentOutOfRangeException(
                          "enumerationLength",
                          String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThan, 0));
            }

            HtmlObjectPrinter printer = new HtmlObjectPrinter(depth, enumerationLength);

            return(new HelperResult(writer => printer.WriteTo(value, writer)));
        }
Пример #3
0
        public void PrintEscapeCharPrintsEscapedCharAsLiteral() {
            // Arrange
            HtmlObjectPrinter printer = new HtmlObjectPrinter(100, 100);
            HtmlElement element = new HtmlElement("span");
            printer.PushElement(element);

            // Act            
            printer.VisitConvertedValue('\t', "\t");

            // Assert
            Assert.AreEqual(1, element.Children.Count);
            HtmlElement child = element.Children[0];
            Assert.AreEqual("'\\t'", child.InnerText);
            Assert.AreEqual("quote", child["class"]);
        }
Пример #4
0
        public void PrintCharPrintsQuotedString() {
            // Arrange
            HtmlObjectPrinter printer = new HtmlObjectPrinter(100, 100);
            HtmlElement element = new HtmlElement("span");
            printer.PushElement(element);

            // Act            
            printer.VisitConvertedValue('x', "x");

            // Assert
            Assert.AreEqual(1, element.Children.Count);
            HtmlElement child = element.Children[0];
            Assert.AreEqual("'x'", child.InnerText);
            Assert.AreEqual("quote", child["class"]);
        }