maui-linux/System.Maui.Xaml/XamlNodeVisitor.cs

52 строки
1.8 KiB
C#
Исходник Обычный вид История

2020-05-19 03:56:25 +03:00
using System;
2016-03-22 23:02:25 +03:00
2020-05-19 03:56:25 +03:00
namespace System.Maui.Xaml
2016-03-22 23:02:25 +03:00
{
interface IXamlNodeVisitor
2016-03-22 23:02:25 +03:00
{
TreeVisitingMode VisitingMode { get; }
2016-03-22 23:02:25 +03:00
bool StopOnDataTemplate { get; }
bool VisitNodeOnDataTemplate { get; }
2016-03-22 23:02:25 +03:00
bool StopOnResourceDictionary { get; }
void Visit(ValueNode node, INode parentNode);
void Visit(MarkupNode node, INode parentNode);
void Visit(ElementNode node, INode parentNode);
void Visit(RootNode node, INode parentNode);
void Visit(ListNode node, INode parentNode);
bool SkipChildren(INode node, INode parentNode);
bool IsResourceDictionary(ElementNode node);
2016-03-22 23:02:25 +03:00
}
enum TreeVisitingMode {
TopDown,
BottomUp
}
class XamlNodeVisitor : IXamlNodeVisitor
2016-03-22 23:02:25 +03:00
{
readonly Action<INode, INode> action;
public XamlNodeVisitor(Action<INode, INode> action, TreeVisitingMode visitingMode = TreeVisitingMode.TopDown, bool stopOnDataTemplate = false, bool visitNodeOnDataTemplate = true)
2016-03-22 23:02:25 +03:00
{
this.action = action;
VisitingMode = visitingMode;
2016-03-22 23:02:25 +03:00
StopOnDataTemplate = stopOnDataTemplate;
VisitNodeOnDataTemplate = visitNodeOnDataTemplate;
2016-03-22 23:02:25 +03:00
}
public TreeVisitingMode VisitingMode { get; }
2016-03-22 23:02:25 +03:00
public bool StopOnDataTemplate { get; }
public bool StopOnResourceDictionary { get; }
public bool VisitNodeOnDataTemplate { get; }
2016-03-22 23:02:25 +03:00
public void Visit(ValueNode node, INode parentNode) => action(node, parentNode);
public void Visit(MarkupNode node, INode parentNode) => action(node, parentNode);
public void Visit(ElementNode node, INode parentNode) => action(node, parentNode);
public void Visit(RootNode node, INode parentNode) => action(node, parentNode);
public void Visit(ListNode node, INode parentNode) => action(node, parentNode);
public bool SkipChildren(INode node, INode parentNode) => false;
public bool IsResourceDictionary(ElementNode node) => false;
2016-03-22 23:02:25 +03:00
}
}