using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using StardewModdingAPI.Toolkit.Serialization.Converters;
namespace StardewModdingAPI.Toolkit.Serialization.Models
{
/// A manifest which describes a mod for SMAPI.
public class Manifest : IManifest
{
/*********
** Accessors
*********/
/// The mod name.
public string Name { get; set; }
/// A brief description of the mod.
public string Description { get; set; }
/// The mod author's name.
public string Author { get; set; }
/// The mod version.
public ISemanticVersion Version { get; set; }
/// The minimum SMAPI version required by this mod, if any.
public ISemanticVersion MinimumApiVersion { get; set; }
/// The name of the DLL in the directory that has the Entry method. Mutually exclusive with .
public string EntryDll { get; set; }
/// The mod which will read this as a content pack. Mutually exclusive with .
[JsonConverter(typeof(ManifestContentPackForConverter))]
public IManifestContentPackFor ContentPackFor { get; set; }
/// The other mods that must be loaded before this mod.
[JsonConverter(typeof(ManifestDependencyArrayConverter))]
public IManifestDependency[] Dependencies { get; set; }
/// The namespaced mod IDs to query for updates (like Nexus:541).
public string[] UpdateKeys { get; set; }
/// The unique mod ID.
public string UniqueID { get; set; }
/// Any manifest fields which didn't match a valid field.
[JsonExtensionData]
public IDictionary ExtraFields { get; set; }
/*********
** Public methods
*********/
/// Construct an instance.
public Manifest() { }
/// 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 modID which will read this as a content pack.
public Manifest(string uniqueID, string name, string author, string description, ISemanticVersion version, string contentPackFor = null)
{
this.Name = name;
this.Author = author;
this.Description = description;
this.Version = version;
this.UniqueID = uniqueID;
this.UpdateKeys = Array.Empty();
this.ContentPackFor = new ManifestContentPackFor { UniqueID = contentPackFor };
}
/// Normalize the model after it's deserialized.
/// The deserialization context.
[OnDeserialized]
public void OnDeserialized(StreamingContext context)
{
this.Dependencies ??= Array.Empty();
this.UpdateKeys ??= Array.Empty();
}
}
}