diff --git a/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs b/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs deleted file mode 100644 index 7b2756e..0000000 --- a/Ghost.Editor.Core/AssetHandle/AssetImporterAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ghost.Editor.Core.AssetHandle; - -[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] -internal class AssetImporterAttribute : Attribute -{ - public string[] SupportedExtensions - { - get; - } - - public AssetImporterAttribute(params string[] supportedExtensions) - { - SupportedExtensions = supportedExtensions; - } -} \ No newline at end of file diff --git a/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs b/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs deleted file mode 100644 index 3ac4d9a..0000000 --- a/Ghost.Editor.Core/AssetHandle/AssetOpenHandlerAttribute .cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Ghost.Editor.Core.AssetHandle; - -[AttributeUsage(AttributeTargets.Method)] -public class AssetOpenHandlerAttribute : Attribute -{ - public string[] Extensions - { - get; - } - - public AssetOpenHandlerAttribute(params string[] extensions) - { - Extensions = extensions.Select(e => e.StartsWith('.') ? e.ToLowerInvariant() : '.' + e.ToLowerInvariant()).ToArray(); - } -} \ No newline at end of file diff --git a/Ghost.Editor.Core/Attributes.cs b/Ghost.Editor.Core/Attributes.cs new file mode 100644 index 0000000..f381aec --- /dev/null +++ b/Ghost.Editor.Core/Attributes.cs @@ -0,0 +1,102 @@ +namespace Ghost.Editor.Core; + +/// +/// The base class for all attributes that can be discovered via . +/// +public abstract class DiscoverableAttributeBase : Attribute; + + +[AttributeUsage(AttributeTargets.Method)] +public class AssetOpenHandlerAttribute : DiscoverableAttributeBase +{ + public string[] Extensions + { + get; + } + + public AssetOpenHandlerAttribute(params string[] extensions) + { + Extensions = extensions.Select(e => e.StartsWith('.') ? e.ToLowerInvariant() : '.' + e.ToLowerInvariant()).ToArray(); + } +} + +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] +internal class AssetImporterAttribute : DiscoverableAttributeBase +{ + public string[] SupportedExtensions + { + get; + } + + public AssetImporterAttribute(params string[] supportedExtensions) + { + SupportedExtensions = supportedExtensions; + } +} + +[AttributeUsage(AttributeTargets.Class)] +public class CustomEditorAttribute : DiscoverableAttributeBase +{ + internal Type TargetType + { + get; + } + + public CustomEditorAttribute(Type targetType) + { + TargetType = targetType; + } +} + +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] +public class EditorInjectionAttribute : DiscoverableAttributeBase +{ + public enum ServiceLifetime + { + Singleton, + Transient, + Scoped + } + + public ServiceLifetime Lifetime + { + get; + } + + public Type? ImplementationType + { + get; + } + + public EditorInjectionAttribute(ServiceLifetime lifetime, Type? implementationType = null) + { + Lifetime = lifetime; + ImplementationType = implementationType; + } +} + +[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; + } +} \ No newline at end of file diff --git a/Ghost.Editor.Core/Controls/ControlsDictionary.xaml b/Ghost.Editor.Core/Controls/ControlsDictionary.xaml index 6120a67..c9b0586 100644 --- a/Ghost.Editor.Core/Controls/ControlsDictionary.xaml +++ b/Ghost.Editor.Core/Controls/ControlsDictionary.xaml @@ -4,7 +4,6 @@ - - + diff --git a/Ghost.Editor.Core/Controls/Internal/ComponentView.cs b/Ghost.Editor.Core/Controls/Internal/ComponentView.cs index b3980af..0e7ae6b 100644 --- a/Ghost.Editor.Core/Controls/Internal/ComponentView.cs +++ b/Ghost.Editor.Core/Controls/Internal/ComponentView.cs @@ -7,7 +7,7 @@ using Microsoft.UI.Xaml.Controls; using System.Reflection; using System.Runtime.InteropServices; -namespace Ghost.Editor.Core.Controls.Internal; +namespace Ghost.Editor.Core.Controls; internal sealed unsafe partial class ComponentView : Control { diff --git a/Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml b/Ghost.Editor.Core/Controls/Internal/ComponentView.xaml similarity index 93% rename from Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml rename to Ghost.Editor.Core/Controls/Internal/ComponentView.xaml index 2800e65..0c0ee8e 100644 --- a/Ghost.Editor.Core/Controls/Internal/ComponentDataView.xaml +++ b/Ghost.Editor.Core/Controls/Internal/ComponentView.xaml @@ -2,7 +2,7 @@ + xmlns:local="using:Ghost.Editor.Core.Controls">