using System; namespace BizHawk.Client.ApiHawk { /// /// This class hold logic interraction for the BizHawkExternalToolUsageAttribute /// This attribute helps ApiHawk to know how a tool can be enabled or not /// [AttributeUsage(AttributeTargets.Assembly)] public sealed class BizHawkExternalToolUsageAttribute : Attribute { #region Fields private BizHawkExternalToolUsage _ToolUsage; private CoreSystem _System; private string _GameHash; #endregion #region cTor(s) /// /// Initialize a new instance of /// /// i.e. what your external tool is for /// that your external tool is used for /// The game hash, unique game ID (see in the game database) public BizHawkExternalToolUsageAttribute(BizHawkExternalToolUsage usage, CoreSystem system, string gameHash) { if (usage == BizHawkExternalToolUsage.EmulatorSpecific && system == CoreSystem.Null) { throw new InvalidOperationException("A system must be set"); } if (usage == BizHawkExternalToolUsage.GameSpecific && gameHash.Trim() == "") { throw new InvalidOperationException("A game hash must be set"); } _ToolUsage = usage; _System = system; _GameHash = gameHash; } /// /// Initialize a new instance of /// /// i.e. what your external tool is for /// that your external tool is used for public BizHawkExternalToolUsageAttribute(BizHawkExternalToolUsage usage, CoreSystem system) :this(usage, system, "") {} /// /// Initialize a new instance of /// public BizHawkExternalToolUsageAttribute() :this(BizHawkExternalToolUsage.Global, CoreSystem.Null, "") { } #endregion #region Properties /// /// Gets the specific system used by the exetrnal tool /// public CoreSystem System { get { return _System; } } /// /// Gets the specific game (hash) used by the exetrnal tool /// public string GameHash { get { return _GameHash; } } /// /// Gets the tool usage /// public BizHawkExternalToolUsage ToolUsage { get { return _ToolUsage; } } #endregion } }