public static string DumpTree(DependencyObject root, DependencyObject excludedNode, IList <string> additionalProperties) { var propertyFilter = new DefaultFilter(); ((List <string>)propertyFilter.PropertyNameAllowList).AddRange(additionalProperties); Visitor visitor = new Visitor(propertyFilter, new DefaultPropertyValueTranslator(), new DefaultVisualTreeLogger()); WalkThroughTree(root, excludedNode, visitor); return(visitor.ToString()); }
/// <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()); }
public static string DumpTree(DependencyObject root, DependencyObject excludedNode, IList <string> additionalProperties, DumpTreeMode mode) { var propertyFilter = new DefaultFilter(); ((List <string>)propertyFilter.PropertyNameAllowList).AddRange(additionalProperties); IPropertyValueTranslator translator = (mode == DumpTreeMode.Json ? new JsonPropertyValueTranslator() as IPropertyValueTranslator : new DefaultPropertyValueTranslator()); IVisualTreeLogger logger = (mode == DumpTreeMode.Json ? new JsonVisualTreeLogger() as IVisualTreeLogger : new DefaultVisualTreeLogger()); Visitor visitor = new Visitor(propertyFilter, translator, logger); WalkThroughTree(root, excludedNode, visitor); return(visitor.ToString()); }