2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding.Internals;
22 namespace Tizen.NUI.Binding
24 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
25 [EditorBrowsable(EditorBrowsableState.Never)]
26 public static class NameScopeExtensions
28 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public static T FindByName<T>(this Element element, string name)
32 return ((INameScope)element).FindByName<T>(name);
35 internal static T FindByName<T>(this INameScope namescope, string name)
37 return (T)namescope?.FindByName(name);
40 private static Stack<Element> elementStack = new Stack<Element>();
42 internal static void PushElement(object element)
44 elementStack.Push((Element)element);
47 internal static void PopElement()
53 /// Used to find the object defined in Xaml file.
55 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 public static T FindByNameInCurrentNameScope<T>(string name)
59 return FindByName<T>(elementStack.Peek(), name);