maui-linux/System.Maui.Xaml/XamlFilePathAttribute.cs

17 строки
608 B
C#

using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System.Maui.Xaml
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class XamlFilePathAttribute : Attribute
{
public XamlFilePathAttribute([CallerFilePath] string filePath = "") => FilePath = filePath;
public string FilePath { get; }
internal static string GetFilePathForObject(object view) => (view?.GetType().GetTypeInfo().GetCustomAttributes(typeof(XamlFilePathAttribute), false).FirstOrDefault() as XamlFilePathAttribute)?.FilePath;
}
}