[NUI] Adjust directory (#903)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Xaml / XamlCompilationAttribute.cs
1 using System;
2 using System.ComponentModel;
3 using System.Reflection;
4 using System.Runtime.CompilerServices;
5
6 namespace Tizen.NUI.Xaml
7 {
8     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
9     [EditorBrowsable(EditorBrowsableState.Never)]
10     [Flags]
11     public enum XamlCompilationOptions
12     {
13         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
14         [EditorBrowsable(EditorBrowsableState.Never)]
15         Skip = 1 << 0,
16
17         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
18         [EditorBrowsable(EditorBrowsableState.Never)]
19         Compile = 1 << 1
20     }
21
22     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
23     [EditorBrowsable(EditorBrowsableState.Never)]
24     [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)]
25     public sealed class XamlCompilationAttribute : Attribute
26     {
27         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28         [EditorBrowsable(EditorBrowsableState.Never)]
29         public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions)
30         {
31             XamlCompilationOptions = xamlCompilationOptions;
32         }
33
34         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35         [EditorBrowsable(EditorBrowsableState.Never)]
36         public XamlCompilationOptions XamlCompilationOptions { get; set; }
37     }
38
39     internal static class XamlCExtensions
40     {
41         public static bool IsCompiled(this Type type)
42         {
43             var attr = type.GetTypeInfo().GetCustomAttribute<XamlCompilationAttribute>();
44             if (attr != null)
45                 return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
46             attr = type.GetTypeInfo().Module.GetCustomAttribute<XamlCompilationAttribute>();
47             if (attr != null)
48                 return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
49             attr = type.GetTypeInfo().Assembly.GetCustomAttribute<XamlCompilationAttribute>();
50             if (attr != null)
51                 return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
52
53             return false;
54         }
55     }
56 }