From 30a0868789466012bab869af4300aef5a9cac108 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 30 May 2024 09:46:43 +0000 Subject: Rename legacy event types --- LibMatrix/LegacyMatrixEvent.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'LibMatrix/LegacyMatrixEvent.cs') diff --git a/LibMatrix/LegacyMatrixEvent.cs b/LibMatrix/LegacyMatrixEvent.cs index 1c1ebf3..5433da3 100644 --- a/LibMatrix/LegacyMatrixEvent.cs +++ b/LibMatrix/LegacyMatrixEvent.cs @@ -13,12 +13,12 @@ using LibMatrix.Extensions; namespace LibMatrix; public class LegacyMatrixEvent { - public static FrozenSet KnownStateEventTypes { get; } = new ClassCollector().ResolveFromAllAccessibleAssemblies().ToFrozenSet(); + public static FrozenSet KnownStateEventTypes { get; } = new ClassCollector().ResolveFromAllAccessibleAssemblies().ToFrozenSet(); public static FrozenDictionary KnownStateEventTypesByName { get; } = KnownStateEventTypes.Aggregate( new Dictionary(), (dict, type) => { - var attrs = type.GetCustomAttributes(); + var attrs = type.GetCustomAttributes(); foreach (var attr in attrs) { if (dict.TryGetValue(attr.EventName, out var existing)) Console.WriteLine($"Duplicate event type '{attr.EventName}' registered for types '{existing.Name}' and '{type.Name}'"); @@ -29,13 +29,13 @@ public class LegacyMatrixEvent { }).OrderBy(x => x.Key).ToFrozenDictionary(); public static Type GetStateEventType(string? type) => - string.IsNullOrWhiteSpace(type) ? typeof(UnknownEventContent) : KnownStateEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownEventContent); + string.IsNullOrWhiteSpace(type) ? typeof(UnknownLegacyEventContent) : KnownStateEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownLegacyEventContent); [JsonIgnore] public Type MappedType => GetStateEventType(Type); [JsonIgnore] - public bool IsLegacyType => MappedType.GetCustomAttributes().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false; + public bool IsLegacyType => MappedType.GetCustomAttributes().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false; [JsonIgnore] public string FriendlyTypeName => MappedType.GetFriendlyNameOrNull() ?? Type; @@ -53,16 +53,16 @@ public class LegacyMatrixEvent { [JsonIgnore] [SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")] - public EventContent? TypedContent { + public LegacyEventContent? TypedContent { get { // if (Type == "m.receipt") { // return null; // } try { var mappedType = GetStateEventType(Type); - if (mappedType == typeof(UnknownEventContent)) + if (mappedType == typeof(UnknownLegacyEventContent)) Console.WriteLine($"Warning: unknown event type '{Type}'"); - var deserialisedContent = (EventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!; + var deserialisedContent = (LegacyEventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!; return deserialisedContent; } catch (JsonException e) { -- cgit 1.4.1