2016-03-22 23:02:25 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
2016-11-16 22:51:53 +03:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Xaml
|
|
|
|
|
{
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum XamlCompilationOptions
|
|
|
|
|
{
|
|
|
|
|
Skip = 1 << 0,
|
|
|
|
|
Compile = 1 << 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)]
|
|
|
|
|
public sealed class XamlCompilationAttribute : Attribute
|
|
|
|
|
{
|
|
|
|
|
public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions)
|
|
|
|
|
{
|
|
|
|
|
XamlCompilationOptions = xamlCompilationOptions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public XamlCompilationOptions XamlCompilationOptions { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 22:39:48 +03:00
|
|
|
|
static class XamlCExtensions
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
|
|
|
|
public static bool IsCompiled(this Type type)
|
|
|
|
|
{
|
|
|
|
|
var attr = type.GetTypeInfo().GetCustomAttribute<XamlCompilationAttribute>();
|
|
|
|
|
if (attr != null)
|
|
|
|
|
return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
|
|
|
|
|
attr = type.GetTypeInfo().Module.GetCustomAttribute<XamlCompilationAttribute>();
|
|
|
|
|
if (attr != null)
|
|
|
|
|
return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
|
|
|
|
|
attr = type.GetTypeInfo().Assembly.GetCustomAttribute<XamlCompilationAttribute>();
|
|
|
|
|
if (attr != null)
|
|
|
|
|
return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|