Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'ricky-dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ricky8955555 committed May 23, 2021
2 parents c63e114 + 82d2b17 commit 0401df3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/Extensions/IOExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Linq;

namespace SeewoHelper
Expand Down Expand Up @@ -58,6 +59,11 @@ public static void MoveTo(this FileSystemInfo fileSystemInfo, string destName, b
}
else if (fileSystemInfo is DirectoryInfo directoryInfo)
{
if (Directory.GetParent(destName).FullName == directoryInfo.FullName)
{
throw new InvalidOperationException("目标文件夹的父文件夹为当前文件夹。");
}

directoryInfo.MoveTo(destName, overwrite);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/SystemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public static class SystemExtensions
/// <param name="terminating">是否终止程序</param>
public static Exception ShowAndLog(this Exception ex, Logger logger, bool terminating = false)
{
MessageBoxUtilities.ShowWarning($"程序给你抛出了异常,异常消息:\n{ex.Message}\n详细信息请查看日志,并提交 Issue,有能力的话也可以发 Pull Request 哦");
logger.Add(new Log(ex.ToString(), terminating ? LogLevel.Fatal : LogLevel.Error));
MessageBoxUtilities.ShowError($"程序给你抛出了异常,异常消息:\n{ex.Message}\n详细信息请查看日志,并提交 Issue,有能力的话也可以发 Pull Request 哦");

return ex;
}

public static string CheckEmpty(this string str) => string.IsNullOrEmpty(str) ? null : str;
public static string IsEmptyOrNull(this string str) => string.IsNullOrEmpty(str) ? null : str;
}
}
2 changes: 1 addition & 1 deletion src/Models/Features/FileSorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Task Sort(FileSortingInfo info) => Task.Run(() =>
Program.Logger.Info($"匹配到:{string.Join(", ", matchedFileSystemInfos)}");
}

var processFileSystemInfos = selectedFileSystemInfos.Distinct(); // 排除重复元素
var processFileSystemInfos = selectedFileSystemInfos.Distinct().Where(x => x.FullName != Path.GetFullPath(info.Path)); // 排除重复元素

Program.Logger.Info($"将要处理:{string.Join(", ", processFileSystemInfos)}");

Expand Down
10 changes: 5 additions & 5 deletions src/Models/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ public class Logger : ObservableCollection<Log>
public string Path { get; }

/// <summary>
/// 添加调试 <see cref="LogLevel"/> 为 <see cref="LogLevel.Debug"/> 的日志
/// 添加 <see cref="LogLevel"/> 为 <see cref="LogLevel.Debug"/> 的日志
/// </summary>
/// <param name="content">内容</param>
public void Debug(string content) => Add(new Log(content, LogLevel.Debug));

/// <summary>
/// 添加调试 <see cref="LogLevel"/> 为 <see cref="LogLevel.Info"/> 的日志
/// 添加 <see cref="LogLevel"/> 为 <see cref="LogLevel.Info"/> 的日志
/// </summary>
/// <param name="content">内容</param>
public void Info(string content) => Add(new Log(content));

/// <summary>
/// 添加调试 <see cref="LogLevel"/> 为 <see cref="LogLevel.Warning"/> 的日志
/// 添加 <see cref="LogLevel"/> 为 <see cref="LogLevel.Warning"/> 的日志
/// </summary>
/// <param name="content">内容</param>
public void Warning(string content) => Add(new Log(content, LogLevel.Warning));

/// <summary>
/// 添加调试 <see cref="LogLevel"/> 为 <see cref="LogLevel.Error"/> 的日志
/// 添加 <see cref="LogLevel"/> 为 <see cref="LogLevel.Error"/> 的日志
/// </summary>
/// <param name="content">内容</param>
public void Error(string content) => Add(new Log(content, LogLevel.Error));

/// <summary>
/// 添加调试 <see cref="LogLevel"/> 为 <see cref="LogLevel.Fatal"/> 的日志
/// 添加 <see cref="LogLevel"/> 为 <see cref="LogLevel.Fatal"/> 的日志
/// </summary>
/// <param name="content">内容</param>
public void Fatal(string content) => Add(new Log(content, LogLevel.Fatal));
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Service
/// <summary>
/// <see cref="ServiceStartMode"/> 对应 <see cref="string"/> 指令词典
/// </summary>
private static readonly Dictionary<ServiceStartMode, string> _serviceStartModeDictionary = new Dictionary<ServiceStartMode, string>()
private static readonly Dictionary<ServiceStartMode, string> _serviceStartModeDictionary = new()
{
[ServiceStartMode.Boot] = "boot",
[ServiceStartMode.System] = "system",
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/FolderBrowserDialogUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static string GetFilePath(string description = "")
var dialog = new FolderBrowserDialog() { Description = description };
dialog.ShowDialog();

return dialog.SelectedPath.CheckEmpty();
return dialog.SelectedPath.IsEmptyOrNull();
}
}
}

0 comments on commit 0401df3

Please sign in to comment.