From fc29fe918a89623544b011c76217aa1ea1975d00 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 15 Jun 2020 18:58:05 -0400 Subject: refactor & optimize event code a bit, drop old support for unknown event handlers --- src/SMAPI/Events/EventPriority.cs | 24 +++++------------------ src/SMAPI/Events/EventPriorityAttribute.cs | 31 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 36 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/EventPriority.cs b/src/SMAPI/Events/EventPriority.cs index 17f5fbb7..e1fb00ac 100644 --- a/src/SMAPI/Events/EventPriority.cs +++ b/src/SMAPI/Events/EventPriority.cs @@ -1,29 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace StardewModdingAPI.Events { - /// - /// Event priority for method handlers. - /// + /// The event priorities for method handlers. public enum EventPriority { - /// - /// Low priority. - /// + /// Low priority. Low = 3, - /// - /// Normal priority. This is the default. - /// + /// The default priority. Normal = 2, - /// - /// High priority. - /// - High = 1, + /// High priority. + High = 1 } } diff --git a/src/SMAPI/Events/EventPriorityAttribute.cs b/src/SMAPI/Events/EventPriorityAttribute.cs index c5683931..207e7862 100644 --- a/src/SMAPI/Events/EventPriorityAttribute.cs +++ b/src/SMAPI/Events/EventPriorityAttribute.cs @@ -1,27 +1,24 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StardewModdingAPI.Events { - /// - /// An attribute for controlling event priority of an event handler. - /// + /// An attribute which specifies the priority for an event handler. [AttributeUsage(AttributeTargets.Method)] - public class EventPriorityAttribute : System.Attribute + public class EventPriorityAttribute : Attribute { - /// - /// The priority for the method marked by this attribute. - /// - public EventPriority Priority { get; } + /********* + ** Accessors + *********/ + /// The event handler priority, relative to other handlers across all mods registered for this event. + internal EventPriority Priority { get; } - /// - /// Constructor. - /// - /// The priority for method marked by this attribute. - public EventPriorityAttribute( EventPriority priority ) + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The event handler priority, relative to other handlers across all mods registered for this event. Higher-priority handlers are notified before lower-priority handlers. + public EventPriorityAttribute(EventPriority priority) { this.Priority = priority; } -- cgit