Skip to content

Commit 0d362b3

Browse files
committed
Add default messageboxShow parameter for functions in FilesFolders
1 parent 5312505 commit 0d362b3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class FilesFolders
2222
/// <param name="sourcePath"></param>
2323
/// <param name="targetPath"></param>
2424
/// <param name="messageBoxExShow"></param>
25-
public static void CopyAll(this string sourcePath, string targetPath, Func<string, MessageBoxResult> messageBoxExShow)
25+
public static void CopyAll(this string sourcePath, string targetPath, Func<string, MessageBoxResult> messageBoxExShow = null)
2626
{
2727
// Get the subdirectories for the specified directory.
2828
DirectoryInfo dir = new DirectoryInfo(sourcePath);
@@ -63,6 +63,7 @@ public static void CopyAll(this string sourcePath, string targetPath, Func<strin
6363
#if DEBUG
6464
throw;
6565
#else
66+
messageBoxExShow ??= MessageBox.Show;
6667
messageBoxExShow(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
6768
RemoveFolderIfExists(targetPath, messageBoxExShow);
6869
#endif
@@ -78,7 +79,7 @@ public static void CopyAll(this string sourcePath, string targetPath, Func<strin
7879
/// <param name="toPath"></param>
7980
/// <param name="messageBoxExShow"></param>
8081
/// <returns></returns>
81-
public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func<string, MessageBoxResult> messageBoxExShow)
82+
public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func<string, MessageBoxResult> messageBoxExShow = null)
8283
{
8384
try
8485
{
@@ -98,6 +99,7 @@ public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPat
9899
#if DEBUG
99100
throw;
100101
#else
102+
messageBoxExShow ??= MessageBox.Show;
101103
messageBoxExShow(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
102104
return false;
103105
#endif
@@ -110,7 +112,7 @@ public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPat
110112
/// </summary>
111113
/// <param name="path"></param>
112114
/// <param name="messageBoxExShow"></param>
113-
public static void RemoveFolderIfExists(this string path, Func<string, MessageBoxResult> messageBoxExShow)
115+
public static void RemoveFolderIfExists(this string path, Func<string, MessageBoxResult> messageBoxExShow = null)
114116
{
115117
try
116118
{
@@ -122,6 +124,7 @@ public static void RemoveFolderIfExists(this string path, Func<string, MessageBo
122124
#if DEBUG
123125
throw;
124126
#else
127+
messageBoxExShow ??= MessageBox.Show;
125128
messageBoxExShow(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
126129
#endif
127130
}
@@ -152,7 +155,7 @@ public static bool FileExists(this string filePath)
152155
/// </summary>
153156
/// <param name="fileOrFolderPath"></param>
154157
/// <param name="messageBoxExShow"></param>
155-
public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResult> messageBoxExShow)
158+
public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResult> messageBoxExShow = null)
156159
{
157160
var psi = new ProcessStartInfo
158161
{
@@ -170,6 +173,7 @@ public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResu
170173
#if DEBUG
171174
throw;
172175
#else
176+
messageBoxExShow ??= MessageBox.Show;
173177
messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath));
174178
#endif
175179
}
@@ -179,10 +183,10 @@ public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResu
179183
/// Open a file with associated application
180184
/// </summary>
181185
/// <param name="filePath">File path</param>
182-
/// <param name="messageBoxExShow"></param>
183186
/// <param name="workingDir">Working directory</param>
184187
/// <param name="asAdmin">Open as Administrator</param>
185-
public static void OpenFile(string filePath, Func<string, MessageBoxResult> messageBoxExShow, string workingDir = "", bool asAdmin = false)
188+
/// <param name="messageBoxExShow"></param>
189+
public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false, Func<string, MessageBoxResult> messageBoxExShow = null)
186190
{
187191
var psi = new ProcessStartInfo
188192
{
@@ -201,6 +205,7 @@ public static void OpenFile(string filePath, Func<string, MessageBoxResult> mess
201205
#if DEBUG
202206
throw;
203207
#else
208+
messageBoxExShow ??= MessageBox.Show;
204209
messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", filePath));
205210
#endif
206211
}

0 commit comments

Comments
 (0)