about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/StateEvent.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-13 20:25:05 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-13 20:25:05 +0200
commit712ad189c99570f686ab779782b2a873e172428e (patch)
tree6102e4719416e71522e9143fa4e06951258bd77c /MatrixRoomUtils.Core/StateEvent.cs
parentFix passwords being visible during editing (diff)
downloadMatrixUtils-712ad189c99570f686ab779782b2a873e172428e.tar.xz
Change syntax style
Diffstat (limited to 'MatrixRoomUtils.Core/StateEvent.cs')
-rw-r--r--MatrixRoomUtils.Core/StateEvent.cs46
1 files changed, 21 insertions, 25 deletions
diff --git a/MatrixRoomUtils.Core/StateEvent.cs b/MatrixRoomUtils.Core/StateEvent.cs
index 6321fb6..a8c1fac 100644
--- a/MatrixRoomUtils.Core/StateEvent.cs
+++ b/MatrixRoomUtils.Core/StateEvent.cs
@@ -4,52 +4,48 @@ using System.Text.Json.Serialization;
 
 namespace MatrixRoomUtils.Core;
 
-public class StateEvent
-{
-    [JsonPropertyName("content")] public dynamic Content { get; set; } = new { };
+public class StateEvent {
+    [JsonPropertyName("content")]
+    public dynamic Content { get; set; } = new { };
+
+    [JsonPropertyName("state_key")]
+    public string StateKey { get; set; } = "";
 
-    [JsonPropertyName("state_key")] public string StateKey { get; set; } = "";
-    [JsonPropertyName("type")] public string Type { get; set; }
-    [JsonPropertyName("replaces_state")] public string? ReplacesState { get; set; }
+    [JsonPropertyName("type")]
+    public string Type { get; set; }
+
+    [JsonPropertyName("replaces_state")]
+    public string? ReplacesState { get; set; }
 
     //extra properties
     [JsonIgnore]
-    public JsonNode ContentAsJsonNode
-    {
+    public JsonNode ContentAsJsonNode {
         get => JsonSerializer.SerializeToNode(Content);
         set => Content = value;
     }
 
-    public StateEvent<T> As<T>() where T : class
-    {
-        return (StateEvent<T>)this;
-    }
-
-    public string dtype
-    {
-        get
-        {
-            string res = GetType().Name switch
-            {
+    public string dtype {
+        get {
+            var res = GetType().Name switch {
                 "StateEvent`1" => $"StateEvent<{Content.GetType().Name}>",
                 _ => GetType().Name
             };
             return res;
         }
     }
+
+    public StateEvent<T> As<T>() where T : class => (StateEvent<T>)this;
 }
 
-public class StateEvent<T> : StateEvent where T : class
-{
-    public StateEvent()
-    {
+public class StateEvent<T> : StateEvent where T : class {
+    public StateEvent() {
         //import base content if not an empty object
-        if (base.Content.GetType() == typeof(T))
-        {
+        if (base.Content.GetType() == typeof(T)) {
             Console.WriteLine($"StateEvent<{typeof(T)}> created with base content of type {base.Content.GetType()}. Importing base content.");
             Content = base.Content;
         }
     }
+
     [JsonPropertyName("content")]
     public new T Content { get; set; }
 }
\ No newline at end of file