Ejemplo n.º 1
0
        public override void VisitKeyValues(object value, IEnumerable<object> keys, Func<object, object> valueSelector, int depth) {
            string id = GetObjectId(value);
            HtmlElement ul = new HtmlElement("ul");
            ul.AddCssClass("typeEnumeration");
            ul["id"] = id;

            PushElement(ul);
            base.VisitKeyValues(value, keys, valueSelector, depth);
            PopElement();

            Current.AppendChild(ul);
        }
Ejemplo n.º 2
0
        public void WriteTo(object value, TextWriter writer) {
            HtmlElement rootElement = new HtmlElement("div");
            rootElement.AddCssClass("objectinfo");

            PushElement(rootElement);
            Visit(value, 0);
            PopElement();

            Debug.Assert(_elementStack.Count == 0, "Stack should be empty");

            // REVIEW: We should only do this once per page/request
            writer.Write(Styles);
            rootElement.WriteTo(writer);
        }
Ejemplo n.º 3
0
 internal void PushElement(HtmlElement element) {
     _elementStack.Push(element);
 }
Ejemplo n.º 4
0
 private static HtmlElement CreateTypeNameSpan(Type type) {
     string typeName = GetTypeName(type);
     HtmlElement span = new HtmlElement("span");
     StringBuilder sb = new StringBuilder();
     // Convert the type name into html elements with different css classes
     foreach (var ch in typeName) {
         if (IsOperator(ch)) {
             if (sb.Length > 0) {
                 span.AppendChild(CreateTypeSpan(sb.ToString()));
                 sb.Clear();
             }
             span.AppendChild(CreateOperatorSpan(ch.ToString()));
         }
         else {
             sb.Append(ch);
         }
     }
     if (sb.Length > 0) {
         span.AppendChild(CreateTypeSpan(sb.ToString()));
     }
     return span;
 }
Ejemplo n.º 5
0
 private static HtmlElement CreateLink(string href, string linkText, string cssClass = null) {
     HtmlElement a = new HtmlElement("a");
     a.SetInnerText(linkText);
     a["href"] = href;
     if (!String.IsNullOrEmpty(cssClass)) {
         a.AddCssClass(cssClass);
     }
     return a;
 }
Ejemplo n.º 6
0
 private static HtmlElement CreateExceptionSpan(ObjectVisitorException exception) {
     HtmlElement span = new HtmlElement("span");
     span.AppendChild(HelpersResources.ObjectInfo_PropertyThrewException);
     span.AppendChild(HtmlElement.CreateSpan(exception.InnerException.Message, "exception"));
     return span;
 }
Ejemplo n.º 7
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"]);
        }
Ejemplo n.º 8
0
 internal static HtmlElement CreateSpan(string innerText, string cssClass = null) {
     var span = new HtmlElement("span");
     span.SetInnerText(innerText);
     if (!String.IsNullOrEmpty(cssClass)) {
         span.AddCssClass(cssClass);
     }
     return span;
 }        
Ejemplo n.º 9
0
        public override void VisitMember(string name, Type type, object value, int depth) {
            HtmlElement li = new HtmlElement("li");

            if (type != null) {
                li.AppendChild(CreateTypeNameSpan(type));
                li.AppendChild(" ");
            }

            li.AppendChild(CreateNameSpan(name));
            li.AppendChild(" = ");

            PushElement(li);

            _excludeTypeName = true;
            base.VisitMember(name, type, value, depth);
            _excludeTypeName = false;

            PopElement();

            Current.AppendChild(li);
        }
Ejemplo n.º 10
0
        public override void VisitMembers(IEnumerable<string> names, Func<string, Type> typeSelector, Func<string, object> valueSelector, int depth) {
            HtmlElement ul = new HtmlElement("ul");
            ul.AddCssClass("typeProperties");

            PushElement(ul);
            base.VisitMembers(names, typeSelector, valueSelector, depth);
            PopElement();

            Current.AppendChild(ul);
        }
Ejemplo n.º 11
0
 public override void VisitEnumeratonLimitExceeded() {
     HtmlElement li = new HtmlElement("li");
     li.AppendChild("...");
     Current.AppendChild(li);
 }
Ejemplo n.º 12
0
 public override void VisitEnumeratedValue(object item, int depth) {
     HtmlElement li = new HtmlElement("li");
     PushElement(li);
     base.VisitEnumeratedValue(item, depth);
     PopElement();
     Current.AppendChild(li);
 }
Ejemplo n.º 13
0
 public override void VisitIndexedEnumeratedValue(int index, object item, int depth) {
     HtmlElement li = new HtmlElement("li");
     li.AppendChild(String.Format(CultureInfo.InvariantCulture, "[{0}] = ", index));
     PushElement(li);
     base.VisitIndexedEnumeratedValue(index, item, depth);
     PopElement();
     Current.AppendChild(li);
 }
Ejemplo n.º 14
0
        public override void VisitEnumerable(IEnumerable enumerable, int depth) {
            string id = GetObjectId(enumerable);

            HtmlElement ul = new HtmlElement("ul");
            ul.AddCssClass("typeEnumeration");
            ul["id"] = id;

            PushElement(ul);
            base.VisitEnumerable(enumerable, depth);
            PopElement();

            Current.AppendChild(ul);
        }
Ejemplo n.º 15
0
        public override void VisitComplexObject(object value, int depth) {
            string id = GetObjectId(value);

            HtmlElement objectElement = new HtmlElement("div");
            objectElement.AddCssClass("typeContainer");
            objectElement["id"] = id;

            PushElement(objectElement);
            base.VisitComplexObject(value, depth);
            PopElement();

            if (objectElement.Children.Any()) {
                Current.AppendChild(objectElement);
            }
        }
Ejemplo n.º 16
0
        public override void VisitKeyValue(object key, object value, int depth) {
            HtmlElement keyElement = new HtmlElement("span");
            PushElement(keyElement);
            Visit(key, depth);
            PopElement();

            HtmlElement valueElement = new HtmlElement("span");
            PushElement(valueElement);
            Visit(value, depth);
            PopElement();

            // Append the elements to the li
            HtmlElement li = new HtmlElement("li");
            li.AppendChild(keyElement);
            li.AppendChild(" = ");
            li.AppendChild(valueElement);
            Current.AppendChild(li);
        }
Ejemplo n.º 17
0
 private static HtmlElement CreateParentSpan(params HtmlElement[] elements) {
     HtmlElement span = new HtmlElement("span");
     foreach (var e in elements) {
         span.AppendChild(e);
     }
     return span;
 }
Ejemplo n.º 18
0
 public HtmlElement AppendChild(HtmlElement e) {
     Children.Add(e);
     return this;
 }
Ejemplo n.º 19
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"]);
        }