From 4ef9ae4b396b0eb37036d4008e8cb40e468dbe73 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Fri, 9 Feb 2024 16:32:46 +0100 Subject: Apply syntax style to LibMatrix --- LibMatrix/StateEvent.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'LibMatrix/StateEvent.cs') diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs index d78939e..019c428 100644 --- a/LibMatrix/StateEvent.cs +++ b/LibMatrix/StateEvent.cs @@ -15,14 +15,12 @@ namespace LibMatrix; public class StateEvent { public static FrozenSet KnownStateEventTypes { get; } = new ClassCollector().ResolveFromAllAccessibleAssemblies().ToFrozenSet(); - + public static FrozenDictionary KnownStateEventTypesByName { get; } = KnownStateEventTypes.Aggregate( new Dictionary(), (dict, type) => { var attrs = type.GetCustomAttributes(); - foreach (var attr in attrs) { - dict[attr.EventName] = type; - } + foreach (var attr in attrs) dict[attr.EventName] = type; return dict; }).ToFrozenDictionary(); @@ -48,7 +46,7 @@ public class StateEvent { new JsonDecimalStringConverter() } }; - + [JsonIgnore] [SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")] public EventContent? TypedContent { @@ -57,7 +55,7 @@ public class StateEvent { // return null; // } try { - var c= (EventContent)RawContent.Deserialize(GetStateEventType(Type), TypedContentSerializerOptions)!; + var c = (EventContent)RawContent.Deserialize(GetStateEventType(Type), TypedContentSerializerOptions)!; return c; } catch (JsonException e) { @@ -68,9 +66,8 @@ public class StateEvent { return null; } set { - if (value is null) { + if (value is null) RawContent?.Clear(); - } else RawContent = JsonSerializer.Deserialize(JsonSerializer.Serialize(value, value.GetType())); } } -- cgit 1.4.1