From bd6b7a75b8dd3a729ff35479c6b5ea25e2982c1b Mon Sep 17 00:00:00 2001 From: sven-n Date: Wed, 13 Dec 2023 21:23:51 +0100 Subject: [PATCH] ToString() should also include the Guid for plugins --- .../Model/PlugInConfiguration.Custom.cs | 17 ++++++++++++++ src/PlugIns/PlugInConfiguration.cs | 23 ++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 src/Persistence/EntityFramework/Model/PlugInConfiguration.Custom.cs diff --git a/src/Persistence/EntityFramework/Model/PlugInConfiguration.Custom.cs b/src/Persistence/EntityFramework/Model/PlugInConfiguration.Custom.cs new file mode 100644 index 000000000..d67d97c5c --- /dev/null +++ b/src/Persistence/EntityFramework/Model/PlugInConfiguration.Custom.cs @@ -0,0 +1,17 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence.EntityFramework.Model; + +/// +/// Custom additions to the generated . +/// +internal partial class PlugInConfiguration +{ + /// + public override string ToString() + { + return $"{base.ToString()} ({this.Id})"; + } +} \ No newline at end of file diff --git a/src/PlugIns/PlugInConfiguration.cs b/src/PlugIns/PlugInConfiguration.cs index 11ff2a8b5..f0c71ef3d 100644 --- a/src/PlugIns/PlugInConfiguration.cs +++ b/src/PlugIns/PlugInConfiguration.cs @@ -70,15 +70,26 @@ public string? CustomConfiguration } } + /// + /// Gets the (display) name of this plugin. + /// + public string Name + { + get + { + var plugInType = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(assembly => assembly.DefinedTypes) + .FirstOrDefault(t => t.GUID == this.TypeId); + var plugInAttribute = plugInType?.GetCustomAttribute(); + + return plugInAttribute?.Name ?? this.TypeId.ToString(); + } + } + /// public override string ToString() { - var plugInType = AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(assembly => assembly.DefinedTypes) - .FirstOrDefault(t => t.GUID == this.TypeId); - var plugInAttribute = plugInType?.GetCustomAttribute(); - - return plugInAttribute?.Name ?? this.TypeId.ToString(); + return this.Name; } ///