Skip to content
Snippets Groups Projects
Commit 5be372cb authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Use C# 6.0 string interpolation.

parent 3557dc84
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@
order++;
numBytes /= 1024;
}
return string.Format("{0:0.#} {1}", numBytes, suffixes[order]);
return $"{numBytes:0.#} {suffixes[order]}";
}
}
}
......@@ -111,13 +111,10 @@ namespace ATxService
string.IsNullOrWhiteSpace(_config.AdminEmailAdress))
return;
var subject = string.Format("{0} - {1} - Admin Notification",
ServiceName, Environment.MachineName);
var body = string.Format("Notification from '{0}' [{1}] (via NLog)\n\n{2}\n\n" +
"NOTE: log messages of the same level will not be sent via email for the\n" +
"next {3} minutes, please check the log file on the corresponding host!",
_config.HostAlias, Environment.MachineName, LogFormatDefault,
_config.AdminNotificationDelta);
var subject = $"{ServiceName} - {Environment.MachineName} - Admin Notification";
var body = $"Notification from '{_config.HostAlias}' [{Environment.MachineName}] (via NLog)\n\n" +
$"{LogFormatDefault}\n\nNOTE: messages of the same log level won't be sent via email for the\n" +
$"next {_config.AdminNotificationDelta} minutes, please check the corresponding log file!";
var logConfig = LogManager.Configuration;
......
......@@ -129,8 +129,7 @@ namespace ATxService
// WARNING: RoboSharp doesn't seem to offer a culture invariant representation
// of the FileClass, so this might fail in non-english environments:
if (processed.FileClass.ToLower().Equals("new file")) {
_transferredFiles.Add(string.Format("{0} ({1})", processed.Name,
Conv.BytesToString(processed.Size)));
_transferredFiles.Add($"{processed.Name} ({Conv.BytesToString(processed.Size)})");
// reset the value for the amount of bytes transferred for the current file:
_status.TransferredBytesCurrentFile = 0;
// now add _txCurFileSize (containing either the size of the previously
......
......@@ -199,7 +199,7 @@ namespace ATxTray
if ((DateTime.Now - _status.LastStatusUpdate).TotalSeconds < 60)
heartBeat = "OK";
if (_txInProgress)
txProgress = _txSize.ToString();
txProgress = _txProgressPct.ToString();
}
UpdateTrayIcon();
......@@ -207,8 +207,7 @@ namespace ATxTray
if (!_statusChanged)
return;
UpdateHoverText(string.Format("AutoTx [svc={0}] [hb={1}] [tx={2}]",
serviceRunning, heartBeat, txProgress));
UpdateHoverText($"AutoTx [svc={serviceRunning}] [hb={heartBeat}] [tx={txProgress}%]");
}
private void MiExitClick(object sender, EventArgs e) {
......@@ -229,9 +228,9 @@ namespace ATxTray
DefaultDirectory = _config.SourceDrive
};
if (dirDialog.ShowDialog() == CommonFileDialogResult.Ok) {
MessageBox.Show("Directory\nselected:\n\n" + dirDialog.FileName +
"\n\nWARNING: adding new transfers is NOT YET IMPLEMENTED!",
"New transfer confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
MessageBox.Show($@"Directory\nselected:\n\n{dirDialog.FileName}\n\n" +
@"WARNING: adding new transfers is NOT YET IMPLEMENTED!",
@"New transfer confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
}
......@@ -317,8 +316,7 @@ namespace ATxTray
_txInProgress = _status.TransferInProgress;
_txSize = _status.CurrentTransferSize;
if (_txInProgress) {
_miTxProgress.Text = @"Transfer in progress (size: " +
Conv.BytesToString(_txSize) + ")";
_miTxProgress.Text = $@"Transfer in progress (size: {Conv.BytesToString(_txSize)})";
_miTxProgress.BackColor = Color.LightGreen;
_notifyIcon.ShowBalloonTip(500, AppTitle,
"New transfer started (size: " +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment