Code clean (#9482)

This commit is contained in:
DHR60
2026-06-06 03:20:06 +00:00
committed by GitHub
parent 4dc9c60b85
commit e6d08c2db1
58 changed files with 169 additions and 217 deletions
@@ -5,13 +5,10 @@ public class ProfilesSelectViewModel : MyReactiveObject
#region private prop
private string _serverFilter = string.Empty;
private Dictionary<string, bool> _dicHeaderSort = new();
private readonly Dictionary<string, bool> _dicHeaderSort = new();
private string _subIndexId = string.Empty;
// ConfigType filter state: default include-mode with all types selected
private List<EConfigType> _filterConfigTypes = new();
private bool _filterExclude = false;
#endregion private prop
@@ -33,18 +30,11 @@ public class ProfilesSelectViewModel : MyReactiveObject
public string ServerFilter { get; set; }
// Include/Exclude filter for ConfigType
public List<EConfigType> FilterConfigTypes
{
get => _filterConfigTypes;
set => this.RaiseAndSetIfChanged(ref _filterConfigTypes, value);
}
[Reactive]
public List<EConfigType> FilterConfigTypes { get; set; }
[Reactive]
public bool FilterExclude
{
get => _filterExclude;
set => this.RaiseAndSetIfChanged(ref _filterExclude, value);
}
public bool FilterExclude { get; set; }
#endregion ObservableCollection
@@ -91,11 +81,11 @@ public class ProfilesSelectViewModel : MyReactiveObject
try
{
FilterExclude = false;
FilterConfigTypes = Enum.GetValues(typeof(EConfigType)).Cast<EConfigType>().ToList();
FilterConfigTypes = Enum.GetValues<EConfigType>().ToList();
}
catch
{
FilterConfigTypes = new();
FilterConfigTypes = [];
}
await RefreshSubscriptions();
@@ -165,14 +155,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
if (lstModel.Count > 0)
{
var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
if (selected != null)
{
SelectedProfile = selected;
}
else
{
SelectedProfile = lstModel.First();
}
SelectedProfile = selected ?? lstModel.First();
}
await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null);
@@ -213,7 +196,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
}).OrderBy(t => t.Sort).ToList();
// Apply ConfigType filter (include or exclude)
if (FilterConfigTypes != null && FilterConfigTypes.Count > 0)
if (FilterConfigTypes is { Count: > 0 })
{
if (FilterExclude)
{
@@ -321,7 +304,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
// External setter for ConfigType filter
public void SetConfigTypeFilter(IEnumerable<EConfigType> types, bool exclude = false)
{
FilterConfigTypes = types?.Distinct().ToList() ?? new List<EConfigType>();
FilterConfigTypes = types?.Distinct().ToList() ?? [];
FilterExclude = exclude;
}