From 53d8023defe19ef943f72964d93dbed40b6f1180 Mon Sep 17 00:00:00 2001 From: crobibero Date: Wed, 30 Sep 2020 17:37:30 -0600 Subject: Update all on-disk plugins --- MediaBrowser.Common/Plugins/LocalPlugin.cs | 113 +++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 MediaBrowser.Common/Plugins/LocalPlugin.cs (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs new file mode 100644 index 000000000..e26631615 --- /dev/null +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace MediaBrowser.Common.Plugins +{ + /// + /// Local plugin struct. + /// + public readonly struct LocalPlugin : IEquatable + { + /// + /// Initializes a new instance of the struct. + /// + /// The plugin id. + /// The plugin name. + /// The plugin version. + /// The plugin path. + public LocalPlugin(Guid id, string name, Version version, string path) + { + Id = id; + Name = name; + Version = version; + Path = path; + DllFiles = new List(); + } + + /// + /// Gets the plugin id. + /// + public Guid Id { get; } + + /// + /// Gets the plugin name. + /// + public string Name { get; } + + /// + /// Gets the plugin version. + /// + public Version Version { get; } + + /// + /// Gets the plugin path. + /// + public string Path { get; } + + /// + /// Gets the list of dll files for this plugin. + /// + public List DllFiles { get; } + + /// + /// == operator. + /// + /// Left item. + /// Right item. + /// Comparison result. + public static bool operator ==(LocalPlugin left, LocalPlugin right) + { + return left.Equals(right); + } + + /// + /// != operator. + /// + /// Left item. + /// Right item. + /// Comparison result. + public static bool operator !=(LocalPlugin left, LocalPlugin right) + { + return !(left == right); + } + + /// + /// Compare two . + /// + /// The first item. + /// The second item. + /// Comparison result. + public static int Compare(LocalPlugin a, LocalPlugin b) + { + var compare = string.Compare(a.Name, b.Name, true, CultureInfo.InvariantCulture); + + // Id is not equal but name is. + if (a.Id != b.Id && compare == 0) + { + compare = a.Id.CompareTo(b.Id); + } + + return compare == 0 ? a.Version.CompareTo(b.Version) : compare; + } + + /// + public override bool Equals(object obj) + { + return obj is LocalPlugin other && this.Equals(other); + } + + /// + public override int GetHashCode() + { + return Name.GetHashCode(StringComparison.OrdinalIgnoreCase); + } + + /// + public bool Equals(LocalPlugin other) + { + return Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase) + && Id.Equals(other.Id); + } + } +} -- cgit v1.2.3 From ee976bb47abe2f16b7d27cd2f789264c5a9ec8d0 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sun, 11 Oct 2020 15:27:11 -0600 Subject: Update MediaBrowser.Common/Plugins/LocalPlugin.cs Co-authored-by: BaronGreenback --- MediaBrowser.Common/Plugins/LocalPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index e26631615..922fad23a 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Common.Plugins /// Comparison result. public static bool operator !=(LocalPlugin left, LocalPlugin right) { - return !(left == right); + return !left.Equals(right); } /// -- cgit v1.2.3 From 73f923c8d50cdf673fe094c33f6e92b77144bedf Mon Sep 17 00:00:00 2001 From: crobibero Date: Sun, 8 Nov 2020 09:31:53 -0700 Subject: Use class instead of struct --- MediaBrowser.Common/Plugins/LocalPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Common/Plugins/LocalPlugin.cs') diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs index 922fad23a..7927c663d 100644 --- a/MediaBrowser.Common/Plugins/LocalPlugin.cs +++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs @@ -7,10 +7,10 @@ namespace MediaBrowser.Common.Plugins /// /// Local plugin struct. /// - public readonly struct LocalPlugin : IEquatable + public class LocalPlugin : IEquatable { /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the class. /// /// The plugin id. /// The plugin name. -- cgit v1.2.3