From 5be372cb52b47fa918552b64e2fe7f19c20e8e37 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Tue, 6 Feb 2018 13:51:03 +0100
Subject: [PATCH] Use C# 6.0 string interpolation.

---
 ATxCommon/Conv.cs         |  2 +-
 ATxService/AutoTx.cs      | 11 ++++-------
 ATxService/RoboCommand.cs |  3 +--
 ATxTray/AutoTxTray.cs     | 14 ++++++--------
 4 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/ATxCommon/Conv.cs b/ATxCommon/Conv.cs
index 004e59d..7d95912 100644
--- a/ATxCommon/Conv.cs
+++ b/ATxCommon/Conv.cs
@@ -16,7 +16,7 @@
                 order++;
                 numBytes /= 1024;
             }
-            return string.Format("{0:0.#} {1}", numBytes, suffixes[order]);
+            return $"{numBytes:0.#} {suffixes[order]}";
         }
     }
 }
diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs
index fd7693c..3f76f46 100644
--- a/ATxService/AutoTx.cs
+++ b/ATxService/AutoTx.cs
@@ -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;
 
diff --git a/ATxService/RoboCommand.cs b/ATxService/RoboCommand.cs
index e8ce5e4..b89188e 100644
--- a/ATxService/RoboCommand.cs
+++ b/ATxService/RoboCommand.cs
@@ -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
diff --git a/ATxTray/AutoTxTray.cs b/ATxTray/AutoTxTray.cs
index 7bea935..e873968 100644
--- a/ATxTray/AutoTxTray.cs
+++ b/ATxTray/AutoTxTray.cs
@@ -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: " +
-- 
GitLab