2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Reflection;
5 using Tizen.NUI.Binding;
7 namespace Tizen.NUI.Xaml
9 class FillResourceDictionariesVisitor : IXamlNodeVisitor
11 public FillResourceDictionariesVisitor(HydrationContext context)
16 HydrationContext Context { get; }
17 Dictionary<INode, object> Values => Context.Values;
19 public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
20 public bool StopOnDataTemplate => true;
21 public bool StopOnResourceDictionary => false;
22 public bool VisitNodeOnDataTemplate => false;
24 public void Visit(ValueNode node, INode parentNode)
26 if (!typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)]))
29 node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
32 public void Visit(MarkupNode node, INode parentNode)
36 public void Visit(ElementNode node, INode parentNode)
38 var value = Values[node];
41 if (typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]) && ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) {
42 if ((propertyName.LocalName == "Resources" ||
43 propertyName.LocalName.EndsWith(".Resources", StringComparison.Ordinal)) && value is ResourceDictionary) {
44 var source = Values[parentNode];
45 ApplyPropertiesVisitor.SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
50 //Only proceed further if the node is a keyless RD
51 if ( parentNode is IElementNode
52 && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
53 && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
54 node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
55 else if ( parentNode is ListNode
56 && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
57 && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
58 node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
61 public void Visit(RootNode node, INode parentNode)
65 public void Visit(ListNode node, INode parentNode)
69 public bool SkipChildren(INode node, INode parentNode)
71 var enode = node as ElementNode;
74 if ( parentNode is IElementNode
75 && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
76 && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
78 if ( parentNode is ListNode
79 && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
80 && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))