diff options
author | Rory& <root@rory.gay> | 2024-10-23 16:12:27 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-10-23 16:12:27 +0200 |
commit | bf1664b254bfc224f0087eb82fdba5235fbd162e (patch) | |
tree | 0545bcf3ed973fa38216f0c59d900095316082b3 /LibMatrix.EventTypes/EventContent.cs | |
parent | Minor cleanups, support for loading access tokens from disk or appservice (diff) | |
download | LibMatrix-bf1664b254bfc224f0087eb82fdba5235fbd162e.tar.xz |
Add helper function to turn event type -> types HEAD github/master master
Diffstat (limited to 'LibMatrix.EventTypes/EventContent.cs')
-rw-r--r-- | LibMatrix.EventTypes/EventContent.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/LibMatrix.EventTypes/EventContent.cs b/LibMatrix.EventTypes/EventContent.cs index d65a47f..a837252 100644 --- a/LibMatrix.EventTypes/EventContent.cs +++ b/LibMatrix.EventTypes/EventContent.cs @@ -1,10 +1,20 @@ +using System.Reflection; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; namespace LibMatrix.EventTypes; -public abstract class EventContent; +public abstract class EventContent { + public static List<string> GetMatchingEventTypes<T>() where T : EventContent { + var type = typeof(T); + var eventTypes = new List<string>(); + foreach (var attr in type.GetCustomAttributes<MatrixEventAttribute>(true)) { + eventTypes.Add(attr.EventName); + } + return eventTypes; + } +} public class UnknownEventContent : TimelineEventContent; |