Use string interpolation wherever possible

Majority of cases still need to go through string.Format() due to localization requirements
This commit is contained in:
Archi
2021-09-27 19:59:00 +02:00
parent de19010820
commit f2d3a2a894
29 changed files with 160 additions and 160 deletions

View File

@@ -138,16 +138,16 @@ namespace ArchiSteamFarm.NLog {
}
if (((chatGroupID == 0) || (chatID == 0)) && (steamID == 0)) {
throw new InvalidOperationException("((" + nameof(chatGroupID) + " || " + nameof(chatID) + ") && " + nameof(steamID) + ")");
throw new InvalidOperationException($"(({nameof(chatGroupID)} || {nameof(chatID)}) && {nameof(steamID)})");
}
StringBuilder loggedMessage = new(previousMethodName + "() " + message + " " + (echo ? "->" : "<-") + " ");
StringBuilder loggedMessage = new($"{previousMethodName}() {message} {(echo ? "->" : "<-")} ");
if ((chatGroupID != 0) && (chatID != 0)) {
loggedMessage.Append(chatGroupID + "-" + chatID);
loggedMessage.Append($"{chatGroupID}-{chatID}");
if (steamID != 0) {
loggedMessage.Append("/" + steamID);
loggedMessage.Append($"/{steamID}");
}
} else if (steamID != 0) {
loggedMessage.Append(steamID);
@@ -225,7 +225,7 @@ namespace ArchiSteamFarm.NLog {
ulong steamID64 = steamID;
string loggedMessage = previousMethodName + "() " + steamID.AccountType + " " + steamID64 + (handled.HasValue ? " = " + handled.Value : "");
string loggedMessage = $"{previousMethodName}() {steamID.AccountType} {steamID64}{(handled.HasValue ? $" = {handled.Value}" : "")}";
LogEventInfo logEventInfo = new(LogLevel.Trace, Logger.Name, loggedMessage) {
Properties = {

View File

@@ -322,7 +322,7 @@ namespace ArchiSteamFarm.NLog {
OnUserInputStart();
try {
Console.Write(@">> " + Strings.EnterCommand);
Console.Write($@">> {Strings.EnterCommand}");
string? command = ConsoleReadLine();
if (string.IsNullOrEmpty(command)) {
@@ -347,12 +347,12 @@ namespace ArchiSteamFarm.NLog {
Bot? targetBot = Bot.Bots?.OrderBy(bot => bot.Key, Bot.BotsComparer).Select(bot => bot.Value).FirstOrDefault();
if (targetBot == null) {
Console.WriteLine(@"<< " + Strings.ErrorNoBotsDefined);
Console.WriteLine($@"<< {Strings.ErrorNoBotsDefined}");
continue;
}
Console.WriteLine(@"<> " + Strings.Executing);
Console.WriteLine($@"<> {Strings.Executing}");
ulong steamOwnerID = ASF.GlobalConfig?.SteamOwnerID ?? GlobalConfig.DefaultSteamOwnerID;
@@ -365,7 +365,7 @@ namespace ArchiSteamFarm.NLog {
continue;
}
Console.WriteLine(@"<< " + response);
Console.WriteLine($@"<< {response}");
} finally {
OnUserInputEnd();
}