From b395e92faae0a197a2d1c2e10e835e38fcc6502c Mon Sep 17 00:00:00 2001 From: Chase W Date: Mon, 15 Jun 2020 15:28:03 -0400 Subject: Implemented event priority attribute --- src/SMAPI/Events/EventPriority.cs | 29 +++++++++++++++++++++++++++++ src/SMAPI/Events/EventPriorityAttribute.cs | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/SMAPI/Events/EventPriority.cs create mode 100644 src/SMAPI/Events/EventPriorityAttribute.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/EventPriority.cs b/src/SMAPI/Events/EventPriority.cs new file mode 100644 index 00000000..17f5fbb7 --- /dev/null +++ b/src/SMAPI/Events/EventPriority.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Events +{ + /// + /// Event priority for method handlers. + /// + public enum EventPriority + { + /// + /// Low priority. + /// + Low = 3, + + /// + /// Normal priority. This is the default. + /// + Normal = 2, + + /// + /// High priority. + /// + High = 1, + } +} diff --git a/src/SMAPI/Events/EventPriorityAttribute.cs b/src/SMAPI/Events/EventPriorityAttribute.cs new file mode 100644 index 00000000..c5683931 --- /dev/null +++ b/src/SMAPI/Events/EventPriorityAttribute.cs @@ -0,0 +1,29 @@ +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. + /// + [AttributeUsage(AttributeTargets.Method)] + public class EventPriorityAttribute : System.Attribute + { + /// + /// The priority for the method marked by this attribute. + /// + public EventPriority Priority { get; } + + /// + /// Constructor. + /// + /// The priority for method marked by this attribute. + public EventPriorityAttribute( EventPriority priority ) + { + this.Priority = priority; + } + } +} -- cgit