diff options
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/ModMetadata.cs')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModMetadata.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs new file mode 100644 index 00000000..5055da75 --- /dev/null +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -0,0 +1,68 @@ +using StardewModdingAPI.Framework.Models; + +namespace StardewModdingAPI.Framework.ModLoading +{ + /// <summary>Metadata for a mod.</summary> + internal class ModMetadata : IModMetadata + { + /********* + ** Accessors + *********/ + /// <summary>The mod's display name.</summary> + public string DisplayName { get; } + + /// <summary>The mod's full directory path.</summary> + public string DirectoryPath { get; } + + /// <summary>The mod manifest.</summary> + public IManifest Manifest { get; } + + /// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary> + public ModDataRecord DataRecord { get; } + + /// <summary>The metadata resolution status.</summary> + public ModMetadataStatus Status { get; private set; } + + /// <summary>The reason the metadata is invalid, if any.</summary> + public string Error { get; private set; } + + /// <summary>The mod instance (if it was loaded).</summary> + public IMod Mod { get; private set; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="displayName">The mod's display name.</param> + /// <param name="directoryPath">The mod's full directory path.</param> + /// <param name="manifest">The mod manifest.</param> + /// <param name="dataRecord">Metadata about the mod from SMAPI's internal data (if any).</param> + public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModDataRecord dataRecord) + { + this.DisplayName = displayName; + this.DirectoryPath = directoryPath; + this.Manifest = manifest; + this.DataRecord = dataRecord; + } + + /// <summary>Set the mod status.</summary> + /// <param name="status">The metadata resolution status.</param> + /// <param name="error">The reason the metadata is invalid, if any.</param> + /// <returns>Return the instance for chaining.</returns> + public IModMetadata SetStatus(ModMetadataStatus status, string error = null) + { + this.Status = status; + this.Error = error; + return this; + } + + /// <summary>Set the mod instance.</summary> + /// <param name="mod">The mod instance to set.</param> + public IModMetadata SetMod(IMod mod) + { + this.Mod = mod; + return this; + } + } +} |