about summary refs log tree commit diff
path: root/LibMatrix.EventTypes/MatrixEventContent.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-05-30 19:07:09 +0000
committerRory& <root@rory.gay>2024-05-30 19:07:09 +0000
commitcf90f02e1f9c9f7d037976cace2b9c49119c741c (patch)
tree3925bd8d689c3f330c217b0f867ba8a241d893e7 /LibMatrix.EventTypes/MatrixEventContent.cs
parentRename legacy event types (diff)
downloadLibMatrix-cf90f02e1f9c9f7d037976cace2b9c49119c741c.tar.xz
Start implementing new event system
Diffstat (limited to 'LibMatrix.EventTypes/MatrixEventContent.cs')
-rw-r--r--LibMatrix.EventTypes/MatrixEventContent.cs26
1 files changed, 26 insertions, 0 deletions
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; + +/// <summary> +/// Extensible Event Content, aims to provide an API similar to JsonNode/JsonObject +/// <seealso cref="System.Text.Json.Nodes.JsonNode"/> +/// <seealso cref="System.Text.Json.Nodes.JsonObject"/> +/// </summary> +public class MatrixEventContent { + // <T> : MatrixEventContent where T : MatrixEventContent<T>, 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