Files
GhostEngine/src/Editor/Ghost.Editor.Core/Attributes.cs
Misaki 5222e801b9 Add asset open handler system and async open support
Introduced AssetOpenHandlerAttribute for extension-based asset open logic.
Implemented async OpenAssetAsync methods in IAssetRegistry and AssetRegistry, using reflection to invoke handlers.
Updated ContentBrowser and ViewModel to support async asset opening.
Refactored Hierarchy initialization and XAML for clarity.
Logger now throws exceptions in DEBUG for errors/asserts.
Removed unused code and cleaned up usings.
2026-05-23 13:05:25 +09:00

60 lines
1.1 KiB
C#

namespace Ghost.Editor.Core;
/// <summary>
/// The base class for all attributes that can be discovered via <see cref="Utilities.TypeCache"/>.
/// </summary>
public abstract class DiscoverableAttributeBase : Attribute;
[AttributeUsage(AttributeTargets.Class)]
public class CustomEditorAttribute : DiscoverableAttributeBase
{
internal Type TargetType
{
get;
}
public CustomEditorAttribute(Type targetType)
{
TargetType = targetType;
}
}
public class AssetOpenHandlerAttribute : DiscoverableAttributeBase
{
internal string[] Extensions
{
get;
}
public AssetOpenHandlerAttribute(params string[] extensions)
{
Extensions = extensions;
}
}
[AttributeUsage(AttributeTargets.Method)]
public sealed class ContextMenuItemAttribute : DiscoverableAttributeBase
{
public string Tag
{
get;
}
public string Name
{
get;
}
public int Group
{
get;
}
public ContextMenuItemAttribute(string tag, string name, int group = 0)
{
Tag = tag;
Name = name;
Group = group;
}
}