From 7c4c53dcb0403c98c4d376f5ae6661c9c0e3a7ee Mon Sep 17 00:00:00 2001 From: ww-rm Date: Tue, 25 Mar 2025 18:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=97=B6=E9=97=B4=E6=A0=87?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SkeletonConverter/SkeletonConverter38.cs | 4 +- SpineViewer/Spine/SkeletonConverter.cs | 18 +------- SpineViewer/Spine/Spine.cs | 14 ------ SpineViewer/Spine/Version.cs | 46 ++++++++++++------- 4 files changed, 33 insertions(+), 49 deletions(-) diff --git a/SpineViewer/Spine/Implementations/SkeletonConverter/SkeletonConverter38.cs b/SpineViewer/Spine/Implementations/SkeletonConverter/SkeletonConverter38.cs index 11dcb68..5d8f59d 100644 --- a/SpineViewer/Spine/Implementations/SkeletonConverter/SkeletonConverter38.cs +++ b/SpineViewer/Spine/Implementations/SkeletonConverter/SkeletonConverter38.cs @@ -8,12 +8,10 @@ using System.Text.Json; using System.Text.Json.Nodes; using SpineRuntime38.Attachments; using System.Globalization; -using static System.Runtime.InteropServices.JavaScript.JSType; -using System.IO; namespace SpineViewer.Spine.Implementations.SkeletonConverter { - [SkeletonConverterImplementation(Version.V38)] + [SpineImplementation(Version.V38)] class SkeletonConverter38 : SpineViewer.Spine.SkeletonConverter { private BinaryReader reader = null; diff --git a/SpineViewer/Spine/SkeletonConverter.cs b/SpineViewer/Spine/SkeletonConverter.cs index c470dbb..b675e3d 100644 --- a/SpineViewer/Spine/SkeletonConverter.cs +++ b/SpineViewer/Spine/SkeletonConverter.cs @@ -12,20 +12,6 @@ using System.Text.Encodings.Web; namespace SpineViewer.Spine { - /// - /// SkeletonConverter 实现类标记 - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] - public class SkeletonConverterImplementationAttribute : Attribute - { - public Version Version { get; } - - public SkeletonConverterImplementationAttribute(Version version) - { - Version = version; - } - } - /// /// SkeletonConverter 基类, 使用静态方法 New 来创建具体版本对象 /// @@ -42,11 +28,11 @@ namespace SpineViewer.Spine /// static SkeletonConverter() { - // 遍历并缓存标记了 SkeletonConverterImplementationAttribute 的类型 + // 遍历并缓存标记了 SpineImplementationAttribute 的类型 var impTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(SkeletonConverter).IsAssignableFrom(t) && !t.IsAbstract); foreach (var type in impTypes) { - var attr = type.GetCustomAttribute(); + var attr = type.GetCustomAttribute(); if (attr is not null) { if (ImplementationTypes.ContainsKey(attr.Version)) diff --git a/SpineViewer/Spine/Spine.cs b/SpineViewer/Spine/Spine.cs index 41834d3..e239bb8 100644 --- a/SpineViewer/Spine/Spine.cs +++ b/SpineViewer/Spine/Spine.cs @@ -18,20 +18,6 @@ using SpineViewer.Exporter; namespace SpineViewer.Spine { - /// - /// Spine 实现类标记 - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] - public class SpineImplementationAttribute : Attribute - { - public Version Version { get; } - - public SpineImplementationAttribute(Version version) - { - Version = version; - } - } - /// /// Spine 基类, 使用静态方法 New 来创建具体版本对象 /// diff --git a/SpineViewer/Spine/Version.cs b/SpineViewer/Spine/Version.cs index ae41742..ee57bc7 100644 --- a/SpineViewer/Spine/Version.cs +++ b/SpineViewer/Spine/Version.cs @@ -9,6 +9,36 @@ using System.Threading.Tasks; namespace SpineViewer.Spine { + /// + /// 支持的 Spine 版本 + /// + public enum Version + { + [Description("")] Auto = 0x0000, + [Description("2.1.x")] V21 = 0x0201, + [Description("3.6.x")] V36 = 0x0306, + [Description("3.7.x")] V37 = 0x0307, + [Description("3.8.x")] V38 = 0x0308, + [Description("4.0.x")] V40 = 0x0400, + [Description("4.1.x")] V41 = 0x0401, + [Description("4.2.x")] V42 = 0x0402, + [Description("4.3.x")] V43 = 0x0403, + } + + /// + /// Spine 实现类标记 + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public class SpineImplementationAttribute : Attribute + { + public Version Version { get; } + + public SpineImplementationAttribute(Version version) + { + Version = version; + } + } + /// /// Spine 版本静态辅助类 /// @@ -61,20 +91,4 @@ namespace SpineViewer.Spine return runtimes.TryGetValue(version, out var val) ? val : GetName(version); } } - - /// - /// 支持的 Spine 版本 - /// - public enum Version - { - [Description("")] Auto = 0x0000, - [Description("2.1.x")] V21 = 0x0201, - [Description("3.6.x")] V36 = 0x0306, - [Description("3.7.x")] V37 = 0x0307, - [Description("3.8.x")] V38 = 0x0308, - [Description("4.0.x")] V40 = 0x0400, - [Description("4.1.x")] V41 = 0x0401, - [Description("4.2.x")] V42 = 0x0402, - [Description("4.3.x")] V43 = 0x0403, - } }