diff options
Diffstat (limited to '')
-rw-r--r-- | LibMatrix.EventTypes/MatrixEventContent.cs | 26 |
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 |