diff --git a/Optimizer/DebugHelper.cs b/Optimizer/DebugHelper.cs index abbea3b..91ab05f 100644 --- a/Optimizer/DebugHelper.cs +++ b/Optimizer/DebugHelper.cs @@ -18,7 +18,7 @@ internal static void FindDifferenceInTwoJsons() var p1 = file1.Properties().ToList(); var p2 = file2.Properties().ToList(); - var missingProps = p1.Where(expected => p2.Where(actual => actual.Name == expected.Name).Count() == 0); + var missingProps = p1.Where(expected => !p2.Where(actual => actual.Name == expected.Name).Any()); StringBuilder sb = new StringBuilder(); foreach (var x in missingProps) diff --git a/Optimizer/Forms/MainForm.cs b/Optimizer/Forms/MainForm.cs index c9c3738..f0bdfc4 100644 --- a/Optimizer/Forms/MainForm.cs +++ b/Optimizer/Forms/MainForm.cs @@ -1192,42 +1192,42 @@ private void LoadNetworkAdapterConfig() if (_currentDNS == null) return; if (_currentDNS.Length == 0) return; - if (PingerHelper.CloudflareDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + if (Array.Exists(PingerHelper.CloudflareDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.CloudflareDNS; return; } - else if (PingerHelper.OpenDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.OpenDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.OpenDNS; return; } - else if (PingerHelper.Quad9DNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.Quad9DNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.Quad9DNS; return; } - else if (PingerHelper.GoogleDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.GoogleDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.GoogleDNS; return; } - else if (PingerHelper.AlternateDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.AlternateDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.AlternateDNS; return; } - else if (PingerHelper.AdguardDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.AdguardDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.AdguardDNS; return; } - else if (PingerHelper.CleanBrowsingDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.CleanBrowsingDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.CleanBrowsingDNS; return; } - else if (PingerHelper.CleanBrowsingAdultDNSv4.Any(x => _currentDNS.Select(y => y.ToString()).Contains(x))) + else if (Array.Exists(PingerHelper.CleanBrowsingAdultDNSv4, x => _currentDNS.Select(y => y.ToString()).Contains(x))) { boxDNS.Text = Constants.CleanBrowsingAdultFilterDNS; return; @@ -1318,7 +1318,7 @@ private void ApplyCustomDNS() txtDns6B.Text }; - if (customDns4.Any(x => string.IsNullOrEmpty(x)) || customDns6.Any(x => string.IsNullOrEmpty(x))) + if (Array.Exists(customDns4, x => string.IsNullOrEmpty(x)) || Array.Exists(customDns6, x => string.IsNullOrEmpty(x))) { return; } @@ -2223,9 +2223,9 @@ private void Translate(bool skipFull = false) if (element == null) continue; - if (element is ToggleCard) + if (element is ToggleCard tc) { - ((ToggleCard)element).LabelText = x.Value; + tc.LabelText = x.Value; continue; } @@ -3352,7 +3352,7 @@ private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e) { foreach (Control c in Utilities.GetSelfAndChildrenRecursive(panelUwp)) { - if (c is MoonCheck) ((MoonCheck)c).Checked = chkSelectAllModernApps.Checked; + if (c is MoonCheck mc) mc.Checked = chkSelectAllModernApps.Checked; } } @@ -3833,7 +3833,7 @@ private async void btnDownloadApps_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(x.Tag)) continue; temp = appsTab.Controls.Find(x.Tag, true); - if (temp.Count() == 0) continue; + if (!temp.Any()) continue; currentCheck = (MoonCheck)temp[0]; if (currentCheck == null) continue; if (!currentCheck.Checked) continue; diff --git a/Optimizer/Forms/StartupRestoreForm.cs b/Optimizer/Forms/StartupRestoreForm.cs index e1bd6b7..7e1f21f 100644 --- a/Optimizer/Forms/StartupRestoreForm.cs +++ b/Optimizer/Forms/StartupRestoreForm.cs @@ -38,7 +38,7 @@ private void RefreshBackups() listRestoreItems.Items.Add(Path.GetFileNameWithoutExtension(x)); } - if (_backups.Count() > 0) listRestoreItems.SelectedIndex = 0; + if (_backups.Any()) listRestoreItems.SelectedIndex = 0; } private void Translate() diff --git a/Optimizer/SilentOps.cs b/Optimizer/SilentOps.cs index d8b211c..207f595 100644 --- a/Optimizer/SilentOps.cs +++ b/Optimizer/SilentOps.cs @@ -171,8 +171,8 @@ internal static void ProcessPinger() { bool atLeastOnePrimary4 = CurrentSilentConfig.Pinger.CustomDNSv4.Length > 0 && CurrentSilentConfig.Pinger.CustomDNSv4.Length < 3; bool atLeastOnePrimary6 = CurrentSilentConfig.Pinger.CustomDNSv6.Length > 0 && CurrentSilentConfig.Pinger.CustomDNSv6.Length < 3; - bool notEmptyDNS4 = CurrentSilentConfig.Pinger.CustomDNSv4.Any(x => !string.IsNullOrEmpty(x)); - bool notEmptyDNS6 = CurrentSilentConfig.Pinger.CustomDNSv6.Any(x => !string.IsNullOrEmpty(x)); + bool notEmptyDNS4 = Array.Exists(CurrentSilentConfig.Pinger.CustomDNSv4, (x => !string.IsNullOrEmpty(x))); + bool notEmptyDNS6 = Array.Exists(CurrentSilentConfig.Pinger.CustomDNSv6, (x => !string.IsNullOrEmpty(x))); if (atLeastOnePrimary4 && atLeastOnePrimary6 && notEmptyDNS4 && notEmptyDNS6) { diff --git a/Optimizer/UWPHelper.cs b/Optimizer/UWPHelper.cs index f52b695..742422b 100644 --- a/Optimizer/UWPHelper.cs +++ b/Optimizer/UWPHelper.cs @@ -42,7 +42,7 @@ internal static List> GetUWPApps(bool showAll) foreach (PSObject x in psResult) { tmp = x.ToString().Replace("@", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("Name=", string.Empty).Replace("InstallLocation=", string.Empty).Trim().Split(';'); - if (!modernApps.Any(i => i.Key == tmp[0])) + if (!modernApps.Exists(i => i.Key == tmp[0])) { modernApps.Add(new KeyValuePair(tmp[0], tmp[1])); } diff --git a/Optimizer/Utilities.cs b/Optimizer/Utilities.cs index ca5ffd6..74d228f 100644 --- a/Optimizer/Utilities.cs +++ b/Optimizer/Utilities.cs @@ -257,7 +257,7 @@ internal static void ActivateMainForm() internal static bool ServiceExists(string serviceName) { - return ServiceController.GetServices().Any(serviceController => serviceController.ServiceName.Equals(serviceName)); + return Array.Exists(ServiceController.GetServices(), (serviceController => serviceController.ServiceName.Equals(serviceName))); } internal static void StopService(string serviceName)