From cf90f02e1f9c9f7d037976cace2b9c49119c741c Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 30 May 2024 19:07:09 +0000 Subject: Start implementing new event system --- LibMatrix.EventTypes/MatrixEventContent.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 LibMatrix.EventTypes/MatrixEventContent.cs (limited to 'LibMatrix.EventTypes/MatrixEventContent.cs') diff --git a/LibMatrix.EventTypes/MatrixEventContent.cs b/LibMatrix.EventTypes/MatrixEventContent.cs new file mode 100644 index 0000000..c30ebb0 --- /dev/null +++ b/LibMatrix.EventTypes/MatrixEventContent.cs @@ -0,0 +1,26 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; + +namespace LibMatrix.EventTypes; + +/// +/// Extensible Event Content, aims to provide an API similar to JsonNode/JsonObject +/// +/// +/// +public class MatrixEventContent { + // : MatrixEventContent where T : MatrixEventContent, new() { + internal JsonNode _json = new JsonObject(); + + public static implicit operator MatrixEventContent(JsonNode json) => new(json); + + [JsonConstructor] + public MatrixEventContent(JsonNode json) { + _json = json; + } + + public MatrixEventContent() { } + + public JsonNode? this[string key] => _json[key]; +} \ No newline at end of file -- cgit 1.4.1