Skip to content

Commit

Permalink
Made a generic singleOrPlural
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikMogensen committed Feb 18, 2024
1 parent 3482f79 commit 9fb14b8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ServiceBus/Helpers/CancelScheduledMessagesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ public static async Task CancelScheduledMessages(ServiceBusHelper2 serviceBusHel
await Task.WhenAll(tasks);
stopwatch.Stop();

Func<string> successesSingleOrPlural = () => successes.Count > 1 ? "messages" : "message";
Func<int, string> singleOrPlural = (c) => c > 1 ? "messages" : "message";

serviceBusHelper.WriteToLog($"Successfully cancelled {successes.Count} scheduled {successesSingleOrPlural()} in {stopwatch.Elapsed}.");

serviceBusHelper.WriteToLog($"Successfully cancelled {successes.Count} " +
$"scheduled {singleOrPlural(successes.Count)} in {stopwatch.Elapsed}.");

if (failures.Count > 0)
{
Func<string> failuresSingleOrPlural = () => failures.Count > 1 ? "messages" : "message";

serviceBusHelper.WriteToLog($"Failed to cancel {failures.Count} {failuresSingleOrPlural()}.");
serviceBusHelper.WriteToLog($"Failed to cancel {failures.Count} " +
$"{singleOrPlural(failures.Count)}.");
}
}
finally
Expand Down

0 comments on commit 9fb14b8

Please sign in to comment.