2 using Tizen.NUI.Binding.Internals;
3 using Tizen.NUI.Xaml.Internals;
4 using Tizen.NUI.Binding;
5 using System.ComponentModel;
7 namespace Tizen.NUI.Xaml
9 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
10 [EditorBrowsable(EditorBrowsableState.Never)]
11 [ContentProperty("Name")]
12 public class ReferenceExtension : IMarkupExtension
14 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
15 [EditorBrowsable(EditorBrowsableState.Never)]
16 public string Name { get; set; }
18 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
19 [EditorBrowsable(EditorBrowsableState.Never)]
20 public object ProvideValue(IServiceProvider serviceProvider)
22 if (serviceProvider == null)
23 throw new ArgumentNullException(nameof(serviceProvider));
24 var valueProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideParentValues;
25 if (valueProvider == null)
26 throw new ArgumentException("serviceProvider does not provide an IProvideValueTarget");
27 var namescopeprovider = serviceProvider.GetService(typeof(INameScopeProvider)) as INameScopeProvider;
28 if (namescopeprovider != null && namescopeprovider.NameScope != null)
30 var value = namescopeprovider.NameScope.FindByName(Name);
35 foreach (var target in valueProvider.ParentObjects)
37 var bo = target as BindableObject;
40 var ns = NameScope.GetNameScope(bo) as INameScope;
43 var value = ns.FindByName(Name);
47 //foreach (var target in valueProvider.ParentObjects)
49 // var ns = target as INameScope;
52 // var value = ns.FindByName(Name);
57 var lineInfo = (serviceProvider?.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo ?? new XmlLineInfo();
58 throw new XamlParseException($"Can not find the object referenced by `{Name}`", lineInfo);