diff --git a/example.csharp.greeter/GreeterPlugin.cs b/example.csharp.greeter/GreeterPlugin.cs index 653fcc0..f5c7045 100644 --- a/example.csharp.greeter/GreeterPlugin.cs +++ b/example.csharp.greeter/GreeterPlugin.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Reflection; using System.Text.Json; using Fabulor.Plugins; @@ -121,13 +122,11 @@ private void LoadTargets() try { var settings = JsonSerializer.Deserialize(File.ReadAllText(SettingsPath)); - foreach (var target in settings?.Targets ?? []) + foreach (var target in (settings?.Targets ?? []) + .Where(target => !string.IsNullOrWhiteSpace(target.Network) + && !string.IsNullOrWhiteSpace(target.Channel))) { - if (!string.IsNullOrWhiteSpace(target.Network) - && !string.IsNullOrWhiteSpace(target.Channel)) - { - _targets[TargetKey(target.Network, target.Channel)] = target; - } + _targets[TargetKey(target.Network, target.Channel)] = target; } } catch (Exception error) when (error is IOException or JsonException or UnauthorizedAccessException)