diff --git a/Dalamud/Game/Text/XivChatType.cs b/Dalamud/Game/Text/XivChatType.cs index 9658078f0..d89fc5f0c 100644 --- a/Dalamud/Game/Text/XivChatType.cs +++ b/Dalamud/Game/Text/XivChatType.cs @@ -1,6 +1,3 @@ -using System; -using System.Linq; - namespace Dalamud.Game.Text { /// @@ -237,77 +234,4 @@ namespace Dalamud.Game.Text [XivChatTypeInfo("Crossworld Linkshell 8", "cw8", 0xFF1E90FF)] CrossLinkShell8 = 107, } - - /// - /// Extension methods for the type. - /// - public static class XivChatTypeExtensions - { - /// - /// Get the InfoAttribute associated with this chat type. - /// - /// The chat type. - /// The info attribute. - public static XivChatTypeInfoAttribute GetDetails(this XivChatType chatType) - { - return chatType.GetAttribute(); - } - } - - /// - /// Storage for relevant information associated with the chat type. - /// - public class XivChatTypeInfoAttribute : Attribute - { - /// - /// Initializes a new instance of the class. - /// - /// The fancy name. - /// The name slug. - /// The default color. - internal XivChatTypeInfoAttribute(string fancyName, string slug, uint defaultColor) - { - this.FancyName = fancyName; - this.Slug = slug; - this.DefaultColor = defaultColor; - } - - /// - /// Gets the "fancy" name of the type. - /// - public string FancyName { get; } - - /// - /// Gets the type name slug or short-form. - /// - public string Slug { get; } - - /// - /// Gets the type default color. - /// - public uint DefaultColor { get; } - } - - /// - /// Extension methods for enums. - /// - public static class EnumExtensions - { - /// - /// Gets an attribute on an enum. - /// - /// The type of attribute to get. - /// The enum value that has an attached attribute. - /// The attached attribute, if any. - public static TAttribute GetAttribute(this Enum value) - where TAttribute : Attribute - { - var type = value.GetType(); - var name = Enum.GetName(type, value); - return type.GetField(name) // I prefer to get attributes this way - .GetCustomAttributes(false) - .OfType() - .SingleOrDefault(); - } - } } diff --git a/Dalamud/Game/Text/XivChatTypeExtensions.cs b/Dalamud/Game/Text/XivChatTypeExtensions.cs new file mode 100644 index 000000000..a26687c47 --- /dev/null +++ b/Dalamud/Game/Text/XivChatTypeExtensions.cs @@ -0,0 +1,20 @@ +using Dalamud.Utility; + +namespace Dalamud.Game.Text +{ + /// + /// Extension methods for the type. + /// + public static class XivChatTypeExtensions + { + /// + /// Get the InfoAttribute associated with this chat type. + /// + /// The chat type. + /// The info attribute. + public static XivChatTypeInfoAttribute GetDetails(this XivChatType chatType) + { + return chatType.GetAttribute(); + } + } +} diff --git a/Dalamud/Game/Text/XivChatTypeInfoAttribute.cs b/Dalamud/Game/Text/XivChatTypeInfoAttribute.cs new file mode 100644 index 000000000..e549ac761 --- /dev/null +++ b/Dalamud/Game/Text/XivChatTypeInfoAttribute.cs @@ -0,0 +1,39 @@ +using System; + +namespace Dalamud.Game.Text +{ + /// + /// Storage for relevant information associated with the chat type. + /// + [AttributeUsage(AttributeTargets.Field)] + public class XivChatTypeInfoAttribute : Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// The fancy name. + /// The name slug. + /// The default color. + internal XivChatTypeInfoAttribute(string fancyName, string slug, uint defaultColor) + { + this.FancyName = fancyName; + this.Slug = slug; + this.DefaultColor = defaultColor; + } + + /// + /// Gets the "fancy" name of the type. + /// + public string FancyName { get; } + + /// + /// Gets the type name slug or short-form. + /// + public string Slug { get; } + + /// + /// Gets the type default color. + /// + public uint DefaultColor { get; } + } +}