Code cleanup: pattern matching and minor fixes

This commit is contained in:
2dust 2026-03-10 17:19:21 +08:00
parent 0c2114d2e1
commit 26f65dd3b2
8 changed files with 11 additions and 12 deletions

View file

@ -95,7 +95,7 @@ public class Global
public const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$";
public static readonly List<string> PolicyGroupDefaultFilterList =
public static readonly List<string> PolicyGroupDefaultFilterList =
[
// All nodes (exclude traffic/expiry info)
PolicyGroupDefaultAllFilter,

View file

@ -81,7 +81,9 @@ public class NodeValidator
{
var transportError = ValidateSingboxTransport(item.ConfigType, net);
if (transportError != null)
{
v.Error(transportError);
}
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
{

View file

@ -1040,8 +1040,8 @@ public static class ConfigHandler
if (profileItem.StreamSecurity.IsNotEmpty())
{
if (profileItem.StreamSecurity != Global.StreamSecurity
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
if (profileItem.StreamSecurity is not Global.StreamSecurity
and not Global.StreamSecurityReality)
{
profileItem.StreamSecurity = string.Empty;
}

View file

@ -9,6 +9,6 @@ public class ServerTestItem
public EConfigType ConfigType { get; set; }
public bool AllowTest { get; set; }
public int QueueNum { get; set; }
public required ProfileItem Profile { get; set; }
public ProfileItem Profile { get; set; }
public ECoreType CoreType { get; set; }
}

View file

@ -243,7 +243,6 @@ public partial class CoreConfigSingboxService
if (Utils.IsIpv6(predefined))
{
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
}
else
{

View file

@ -8,9 +8,9 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
public ClashConnectionsView()
{
InitializeComponent();
_config = AppManager.Instance.Config;
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
@ -65,7 +65,7 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
{
ViewModel?.ClashConnectionClose(false);
}
#region UI
private void RestoreUI()

View file

@ -97,8 +97,7 @@ public partial class ProfilesSelectWindow
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
{
var colHeader = sender as DataGridColumnHeader;
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
{
return;
}

View file

@ -233,8 +233,7 @@ public partial class ProfilesView
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
{
var colHeader = sender as DataGridColumnHeader;
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
{
return;
}