diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-06-15 21:34:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 21:34:46 -0400 |
commit | e759332135df95465ceefa74af6fb936d2cf71f1 (patch) | |
tree | 74a7626f14d0f737ddc19c45dda646885ea1cd49 /src/SMAPI/Events | |
parent | ff7b9a0251484bfb9737f9c6c05637f63efa9551 (diff) | |
parent | 02e7318d2b99d311a328746b23a359364575f0c5 (diff) | |
download | SMAPI-e759332135df95465ceefa74af6fb936d2cf71f1.tar.gz SMAPI-e759332135df95465ceefa74af6fb936d2cf71f1.tar.bz2 SMAPI-e759332135df95465ceefa74af6fb936d2cf71f1.zip |
Merge pull request #723 from spacechase0/event-priority
Implement event priority attribute
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r-- | src/SMAPI/Events/EventPriority.cs | 15 | ||||
-rw-r--r-- | src/SMAPI/Events/EventPriorityAttribute.cs | 26 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/SMAPI/Events/EventPriority.cs b/src/SMAPI/Events/EventPriority.cs new file mode 100644 index 00000000..1efb4e2a --- /dev/null +++ b/src/SMAPI/Events/EventPriority.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Events +{ + /// <summary>The event priorities for method handlers.</summary> + public enum EventPriority + { + /// <summary>Low priority.</summary> + Low = -1000, + + /// <summary>The default priority.</summary> + Normal = 0, + + /// <summary>High priority.</summary> + High = 1000 + } +} diff --git a/src/SMAPI/Events/EventPriorityAttribute.cs b/src/SMAPI/Events/EventPriorityAttribute.cs new file mode 100644 index 00000000..207e7862 --- /dev/null +++ b/src/SMAPI/Events/EventPriorityAttribute.cs @@ -0,0 +1,26 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// <summary>An attribute which specifies the priority for an event handler.</summary> + [AttributeUsage(AttributeTargets.Method)] + public class EventPriorityAttribute : Attribute + { + /********* + ** Accessors + *********/ + /// <summary>The event handler priority, relative to other handlers across all mods registered for this event.</summary> + internal EventPriority Priority { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="priority">The event handler priority, relative to other handlers across all mods registered for this event. Higher-priority handlers are notified before lower-priority handlers.</param> + public EventPriorityAttribute(EventPriority priority) + { + this.Priority = priority; + } + } +} |