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