2 using System.Collections.Generic;
3 using System.ComponentModel;
5 using Tizen.NUI.Binding;
8 namespace Tizen.NUI.Binding.Internals
10 internal class NameScope : INameScope
12 public static readonly BindableProperty NameScopeProperty = BindableProperty.CreateAttached("NameScope", typeof(INameScope), typeof(NameScope), default(INameScope));
14 readonly Dictionary<string, object> _names = new Dictionary<string, object>();
16 object INameScope.FindByName(string name)
18 if (_names.ContainsKey(name))
23 void INameScope.RegisterName(string name, object scopedElement)
25 if (_names.ContainsKey(name))
26 throw new ArgumentException("An element with the same key already exists in NameScope", "name");
28 _names[name] = scopedElement;
32 void INameScope.RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo)
36 ((INameScope)this).RegisterName(name, scopedElement);
38 catch (ArgumentException)
40 throw new XamlParseException(string.Format("An element with the name \"{0}\" already exists in this NameScope", name), xmlLineInfo);
44 void INameScope.UnregisterName(string name)
49 public static INameScope GetNameScope(BindableObject bindable)
51 return (INameScope)bindable.GetValue(NameScopeProperty);
54 public static void SetNameScope(BindableObject bindable, INameScope value)
56 bindable.SetValue(NameScopeProperty, value);