From aa3c45101b03827d17591b2b3efa4fdb137fc756 Mon Sep 17 00:00:00 2001 From: real-zony Date: Sun, 30 Jun 2024 17:50:49 +0800 Subject: [PATCH] feat: Added a comparator for MusicInfo. --- src/ZonyLrcTools.Common/MusicInfo.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ZonyLrcTools.Common/MusicInfo.cs b/src/ZonyLrcTools.Common/MusicInfo.cs index 060b677..6f149a2 100644 --- a/src/ZonyLrcTools.Common/MusicInfo.cs +++ b/src/ZonyLrcTools.Common/MusicInfo.cs @@ -57,5 +57,25 @@ namespace ZonyLrcTools.Common [GeneratedRegex(@"[<>:""/\\|?*]")] private static partial Regex InvalidFilePathRegex(); + + public static bool operator ==(MusicInfo? left, MusicInfo? right) + { + if (left is null && right is null) + { + return true; + } + + if (left is null || right is null) + { + return false; + } + + return left.FilePath == right.FilePath; + } + + public static bool operator !=(MusicInfo? left, MusicInfo? right) + { + return !(left == right); + } } } \ No newline at end of file