/// <summary>
        /// The main entry point to the library. Produces a tre dump starting at <paramref name="root"/>
        /// </summary>
        /// <param name="root">The node to start the walk from</param>
        /// <param name="excludedNode">A node to exclude, or null</param>
        /// <param name="additionalProperties">a list of additional properties to extract from each node</param>
        /// <param name="attachedProps">a list of attached properties to extract from each node</param>
        /// <returns></returns>
        public static string DumpTree(DependencyObject root, DependencyObject excludedNode, IEnumerable <string> additionalProperties, IEnumerable <AttachedProperty> attachedProps)
        {
            var propertyFilter = new DefaultFilter();

            ((List <string>)propertyFilter.PropertyNameAllowList).AddRange(additionalProperties);
            propertyFilter.AttachedProperties = attachedProps;

            IPropertyValueTranslator translator = new JsonPropertyValueTranslator();
            IVisualTreeLogger        logger     = new JsonVisualTreeLogger();
            Visitor visitor = new Visitor(propertyFilter, translator, logger);

            WalkThroughTree(root, excludedNode, visitor);

            return(visitor.ToString());
        }
Beispiel #2
0
 public void BeginNode(int indent, string nodeName, DependencyObject obj)
 {
     AppendLogger(indent, "{\n", false);
     isFirstElement = true;
     LogProperty(indent + 2, "XamlType", JsonPropertyValueTranslator.Quote(nodeName));
 }
 public void BeginNode(int indent, string nodeName, DependencyObject obj, bool hasProperties)
 {
     AppendLogger(indent, "{");
     LogProperty(indent + 2, "XamlType", JsonPropertyValueTranslator.Quote(nodeName), !hasProperties);
 }