Follow formatting NUI
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Xaml / XamlResourceIdAttribute.cs
1 using System;
2 using System.ComponentModel;
3 using System.Reflection;
4
5 namespace Tizen.NUI.Xaml
6 {
7     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
8     [EditorBrowsable(EditorBrowsableState.Never)]
9     [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
10     public sealed class XamlResourceIdAttribute : Attribute
11     {
12         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
13         [EditorBrowsable(EditorBrowsableState.Never)]
14         public string ResourceId { get; set; }
15
16         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
17         [EditorBrowsable(EditorBrowsableState.Never)]
18         public string Path { get; set; }
19
20         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
21         [EditorBrowsable(EditorBrowsableState.Never)]
22         public Type Type { get; set; }
23
24         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
25         [EditorBrowsable(EditorBrowsableState.Never)]
26         public XamlResourceIdAttribute(string resourceId, string path, Type type)
27         {
28             ResourceId = resourceId;
29             Path = path;
30             Type = type;
31         }
32
33         internal static string GetResourceIdForType(Type type)
34         {
35             var assembly = type.GetTypeInfo().Assembly;
36             foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>())
37             {
38                 if (xria.Type == type)
39                     return xria.ResourceId;
40             }
41             return null;
42         }
43
44         internal static string GetPathForType(Type type)
45         {
46             var assembly = type.GetTypeInfo().Assembly;
47             foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>())
48             {
49                 if (xria.Type == type)
50                     return xria.Path;
51             }
52             return null;
53         }
54
55         internal static string GetResourceIdForPath(Assembly assembly, string path)
56         {
57             foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>())
58             {
59                 if (xria.Path == path)
60                     return xria.ResourceId;
61             }
62             return null;
63         }
64
65         internal static Type GetTypeForResourceId(Assembly assembly, string resourceId)
66         {
67             foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>())
68             {
69                 if (xria.ResourceId == resourceId)
70                     return xria.Type;
71             }
72             return null;
73         }
74
75         internal static Type GetTypeForPath(Assembly assembly, string path)
76         {
77             foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>())
78             {
79                 if (xria.Path == path)
80                     return xria.Type;
81             }
82             return null;
83         }
84     }
85 }