about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Core')
-rw-r--r--MatrixRoomUtils.Core/Extensions/ObjectExtensions.cs3
-rw-r--r--MatrixRoomUtils.Core/StateEvent.cs15
2 files changed, 16 insertions, 2 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/ObjectExtensions.cs b/MatrixRoomUtils.Core/Extensions/ObjectExtensions.cs

index aa1832d..5aa9645 100644 --- a/MatrixRoomUtils.Core/Extensions/ObjectExtensions.cs +++ b/MatrixRoomUtils.Core/Extensions/ObjectExtensions.cs
@@ -4,11 +4,12 @@ namespace MatrixRoomUtils.Core.Extensions; public static class ObjectExtensions { - public static string ToJson(this object obj, bool indent = true, bool ignoreNull = false) + public static string ToJson(this object obj, bool indent = true, bool ignoreNull = false, bool unsafeContent = false) { var jso = new JsonSerializerOptions(); if(indent) jso.WriteIndented = true; if(ignoreNull) jso.IgnoreNullValues = true; + if(unsafeContent) jso.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping; return JsonSerializer.Serialize(obj, jso); } } \ No newline at end of file diff --git a/MatrixRoomUtils.Core/StateEvent.cs b/MatrixRoomUtils.Core/StateEvent.cs
index f98d963..6321fb6 100644 --- a/MatrixRoomUtils.Core/StateEvent.cs +++ b/MatrixRoomUtils.Core/StateEvent.cs
@@ -24,6 +24,19 @@ public class StateEvent { return (StateEvent<T>)this; } + + public string dtype + { + get + { + string res = GetType().Name switch + { + "StateEvent`1" => $"StateEvent<{Content.GetType().Name}>", + _ => GetType().Name + }; + return res; + } + } } public class StateEvent<T> : StateEvent where T : class @@ -38,5 +51,5 @@ public class StateEvent<T> : StateEvent where T : class } } [JsonPropertyName("content")] - public T Content { get; set; } + public new T Content { get; set; } } \ No newline at end of file