From f3a1bcc01f154f5f2070b127bfd79dc953541975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Wed, 24 Feb 2021 16:03:10 +0800 Subject: [PATCH] revise access of UserSelectedrecord, Histroy, TopMost setter access to private --- Flow.Launcher/Storage/QueryHistory.cs | 5 +++-- Flow.Launcher/Storage/TopMostRecord.cs | 12 ++---------- Flow.Launcher/Storage/UserSelectedRecord.cs | 11 ++--------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Flow.Launcher/Storage/QueryHistory.cs b/Flow.Launcher/Storage/QueryHistory.cs index 2b2103605..a5383b179 100644 --- a/Flow.Launcher/Storage/QueryHistory.cs +++ b/Flow.Launcher/Storage/QueryHistory.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; using System.Linq; -using Flow.Launcher.Plugin; +using System.Text.Json.Serialization; namespace Flow.Launcher.Storage { public class History { - public List Items { get; set; } = new List(); + [JsonInclude] + public List Items { get; private set; } = new List(); private int _maxHistory = 300; diff --git a/Flow.Launcher/Storage/TopMostRecord.cs b/Flow.Launcher/Storage/TopMostRecord.cs index c92ef4956..052c296cd 100644 --- a/Flow.Launcher/Storage/TopMostRecord.cs +++ b/Flow.Launcher/Storage/TopMostRecord.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.Linq; -using System.Text.Json; using System.Text.Json.Serialization; using Flow.Launcher.Plugin; @@ -9,14 +7,8 @@ namespace Flow.Launcher.Storage // todo this class is not thread safe.... but used from multiple threads. public class TopMostRecord { - /// - /// You should not directly access this field - /// - /// It is public due to System.Text.Json limitation in version 3.1 - /// - /// - /// TODO: Set it to private - public Dictionary records { get; set; } = new Dictionary(); + [JsonInclude] + public Dictionary records { get; private set; } = new Dictionary(); internal bool IsTopMost(Result result) { diff --git a/Flow.Launcher/Storage/UserSelectedRecord.cs b/Flow.Launcher/Storage/UserSelectedRecord.cs index bc7a2da73..fd3d87fc4 100644 --- a/Flow.Launcher/Storage/UserSelectedRecord.cs +++ b/Flow.Launcher/Storage/UserSelectedRecord.cs @@ -7,15 +7,8 @@ namespace Flow.Launcher.Storage { public class UserSelectedRecord { - /// - /// You should not directly access this field - /// - /// It is public due to System.Text.Json limitation in version 3.1 - /// - /// - /// TODO: Set it to private - [JsonPropertyName("records")] - public Dictionary records { get; set; } + [JsonInclude] + public Dictionary records { get; private set; } public UserSelectedRecord() {