Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Fix ToString method in extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBron committed Dec 2, 2022
1 parent 4506046 commit 63f70dd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ DESCEnd/
/DES-Core/outs-win
/DES-Core/outs-linux
DES-Core/DESrv.Config/obj/
/DES-Core/DESrv.PDK/obj/Debug/net6.0
2 changes: 1 addition & 1 deletion DES-Core/DESrv.Core/DESrv.Core.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>DESCore</ActiveDebugProfile>
<_LastSelectedProfileId>C:\Users\EgorBron\projects\DES\DES-Core\DESrv.Core\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>C:\Users\EgorBron\projects\DES\DES-Core\DESrv.Core\Properties\PublishProfiles\PublishBuildWindows.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
27 changes: 16 additions & 11 deletions DES-Core/DESrv.PDK/AbstractPDKExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ public class ExtensionMetadata {
/// <summary>
/// ID of extension. It mustn't contain spaces and special symbols (for example dots)
/// </summary>
public string ID { get; internal set; } = "";
public string ID { get; set; } = "";
/// <summary>
/// Type of extension: 1 - plugin, 2 - addon
/// </summary>
public int ExtType { get; internal set; } = 0;
public int ExtType { get; set; } = 0;
/// <summary>
/// Readable name of extension
/// </summary>
public string Name { get; internal set; } = "";
public string Name { get; set; } = "";
/// <summary>
/// Description for extension
/// </summary>
public string Description { get; internal set; } = "";
public string Description { get; set; } = "";
/// <summary>
/// Version of extension
/// </summary>
public string Version { get; internal set; } = "-0.0.0";
public string Version { get; set; } = "-0.0.0";
/// <summary>
/// Version of DESrv what this extension supports
/// </summary>
public string DESVersion { get; internal set; } = "-0.0.0";
public string DESVersion { get; set; } = "-0.0.0";
/// <summary>
/// Author of extension
/// </summary>
public string Author { get; internal set; } = "";
public string Author { get; set; } = "";
/// <summary>
/// Array of dependencies for extension
/// </summary>
public string[] Dependencies { get; internal set; } = Array.Empty<string>();
public string[] Dependencies { get; set; } = Array.Empty<string>();
/// <summary>
/// ID of extension to which this extension refers (for addons)
/// </summary>
public string Reference { get; internal set; } = "";
public string Reference { get; set; } = "";
}
/// <summary>
/// An abstract class that provides an interface to implement the information and functionality of an extension
Expand Down Expand Up @@ -71,8 +71,13 @@ public abstract class AbstractPDKExtension : AbstractFPReaderInClass {
public virtual void Unload() { }

public sealed override string ToString() {
var extype = (int)GetFieldValue("ExtType");
var whatisthis = extype == 1 || extype == 2 ? (extype == 1 ? "plugin" : "addon") : "unknown";
var metadata = GetPropertyValue("Metadata") as ExtensionMetadata;
var whatisthis = metadata.ExtType switch {
1 => "plugin",
2 => "addon",
3 => "random",
_ => "unknown",
};
return $"Extension {{type={whatisthis} id={GetFieldValue("ID") as string} version={GetFieldValue("Version")}}}";
}

Expand Down

0 comments on commit 63f70dd

Please sign in to comment.