Skip to content

Commit 26f65dd

Browse files
committed
Code cleanup: pattern matching and minor fixes
1 parent 0c2114d commit 26f65dd

8 files changed

Lines changed: 11 additions & 12 deletions

File tree

v2rayN/ServiceLib/Global.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class Global
9595

9696
public const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$";
9797

98-
public static readonly List<string> PolicyGroupDefaultFilterList =
98+
public static readonly List<string> PolicyGroupDefaultFilterList =
9999
[
100100
// All nodes (exclude traffic/expiry info)
101101
PolicyGroupDefaultAllFilter,

v2rayN/ServiceLib/Handler/Builder/NodeValidator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ private static void ValidateNodeAndCoreSupport(ProfileItem item, ECoreType coreT
8181
{
8282
var transportError = ValidateSingboxTransport(item.ConfigType, net);
8383
if (transportError != null)
84+
{
8485
v.Error(transportError);
86+
}
8587

8688
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
8789
{

v2rayN/ServiceLib/Handler/ConfigHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ public static async Task<int> AddServerCommon(Config config, ProfileItem profile
10401040

10411041
if (profileItem.StreamSecurity.IsNotEmpty())
10421042
{
1043-
if (profileItem.StreamSecurity != Global.StreamSecurity
1044-
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
1043+
if (profileItem.StreamSecurity is not Global.StreamSecurity
1044+
and not Global.StreamSecurityReality)
10451045
{
10461046
profileItem.StreamSecurity = string.Empty;
10471047
}

v2rayN/ServiceLib/Models/ServerTestItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public class ServerTestItem
99
public EConfigType ConfigType { get; set; }
1010
public bool AllowTest { get; set; }
1111
public int QueueNum { get; set; }
12-
public required ProfileItem Profile { get; set; }
12+
public ProfileItem Profile { get; set; }
1313
public ECoreType CoreType { get; set; }
1414
}

v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ private void GenDnsRules()
243243
if (Utils.IsIpv6(predefined))
244244
{
245245
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
246-
247246
}
248247
else
249248
{

v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
88
public ClashConnectionsView()
99
{
1010
InitializeComponent();
11-
11+
1212
_config = AppManager.Instance.Config;
13-
13+
1414
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
1515
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
1616

@@ -65,7 +65,7 @@ private void btnClose_Click(object? sender, RoutedEventArgs e)
6565
{
6666
ViewModel?.ClashConnectionClose(false);
6767
}
68-
68+
6969
#region UI
7070

7171
private void RestoreUI()

v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
9797

9898
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
9999
{
100-
var colHeader = sender as DataGridColumnHeader;
101-
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
100+
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
102101
{
103102
return;
104103
}

v2rayN/v2rayN/Views/ProfilesView.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
233233

234234
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
235235
{
236-
var colHeader = sender as DataGridColumnHeader;
237-
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
236+
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
238237
{
239238
return;
240239
}

0 commit comments

Comments
 (0)