using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace StardewModdingAPI.Framework.Models
{
/// A manifest which describes a mod for SMAPI.
internal class Manifest : IManifest
{
/*********
** Accessors
*********/
/// The mod name.
public string Name { get; }
/// A brief description of the mod.
public string Description { get; }
/// The mod author's name.
public string Author { get; }
/// The mod version.
public ISemanticVersion Version { get; }
/// The minimum SMAPI version required by this mod, if any.
public ISemanticVersion MinimumApiVersion { get; }
/// The name of the DLL in the directory that has the method. Mutually exclusive with .
public string EntryDll { get; }
/// The mod which will read this as a content pack. Mutually exclusive with .
public IManifestContentPackFor ContentPackFor { get; }
/// The other mods that must be loaded before this mod.
public IManifestDependency[] Dependencies { get; }
/// The namespaced mod IDs to query for updates (like Nexus:541).
public string[] UpdateKeys { get; set; }
/// The unique mod ID.
public string UniqueID { get; }
/// Any manifest fields which didn't match a valid field.
[JsonExtensionData]
public IDictionary ExtraFields { get; }
/*********
** Public methods
*********/
/// Construct an instance.
/// The toolkit manifest.
public Manifest(Toolkit.Serialisation.Models.Manifest manifest)
: this(
uniqueID: manifest.UniqueID,
name: manifest.Name,
author: manifest.Author,
description: manifest.Description,
version: manifest.Version != null ? new SemanticVersion(manifest.Version) : null,
entryDll: manifest.EntryDll,
minimumApiVersion: manifest.MinimumApiVersion != null ? new SemanticVersion(manifest.MinimumApiVersion) : null,
contentPackFor: manifest.ContentPackFor != null ? new ManifestContentPackFor(manifest.ContentPackFor) : null,
dependencies: manifest.Dependencies?.Select(p => p != null ? (IManifestDependency)new ManifestDependency(p) : null).ToArray(),
updateKeys: manifest.UpdateKeys,
extraFields: manifest.ExtraFields
)
{ }
/// Construct an instance for a transitional content pack.
/// The unique mod ID.
/// The mod name.
/// The mod author's name.
/// A brief description of the mod.
/// The mod version.
/// The name of the DLL in the directory that has the method. Mutually exclusive with .
/// The minimum SMAPI version required by this mod, if any.
/// The modID which will read this as a content pack. Mutually exclusive with .
/// The other mods that must be loaded before this mod.
/// The namespaced mod IDs to query for updates (like Nexus:541).
/// Any manifest fields which didn't match a valid field.
public Manifest(string uniqueID, string name, string author, string description, ISemanticVersion version, string entryDll = null, ISemanticVersion minimumApiVersion = null, IManifestContentPackFor contentPackFor = null, IManifestDependency[] dependencies = null, string[] updateKeys = null, IDictionary extraFields = null)
{
this.Name = name;
this.Author = author;
this.Description = description;
this.Version = version;
this.UniqueID = uniqueID;
this.UpdateKeys = new string[0];
this.EntryDll = entryDll;
this.ContentPackFor = contentPackFor;
this.MinimumApiVersion = minimumApiVersion;
this.Dependencies = dependencies ?? new IManifestDependency[0];
this.UpdateKeys = updateKeys ?? new string[0];
this.ExtraFields = extraFields;
}
}
}