using System; using System.IO; using ColdMint.scripts.serialization; namespace ColdMint.scripts.mod; /// /// Module manifest file /// 模组清单文件 /// public class ModManifest { /// /// 模组Id /// public string? Id { get; set; } /// /// Mod name /// 模组名称 /// public string? Name { get; set; } /// /// Dll path list of the mod /// 模组的Dll路径列表 /// /// ///Allow relative paths, such as:... / Points to the parent directory. ///允许使用相对路径,例如: ../指向上级目录。 /// public string[]? DllList { get; set; } /// /// Pck path list of mod /// 模组的Pck路径列表 /// /// ///Allow relative paths, such as:... / Points to the parent directory. ///允许使用相对路径,例如: ../指向上级目录。 /// public string[]? PckList { get; set; } /// /// Creates module list information from a path /// 从路径创建模组清单信息 /// /// ///filePath ///文件路径 /// /// ///When a given path is not to end throw this exception. ///当给定的路径不是以结尾时抛出此异常。 /// /// ///This exception is thrown when the given path does not exist. ///当给定的路径不存在时,抛出此异常。 /// /// public static ModManifest? CreateModManifestFromPath(string filePath) { if (!filePath.EndsWith(Config.ModManifestFileName)) { throw new ArgumentException("path must end with " + Config.ModManifestFileName + "."); } if (!File.Exists(filePath)) { throw new FileNotFoundException("The file at " + filePath + " does not exist."); } var content = File.ReadAllText(filePath); return YamlSerialization.Deserialize(content); } }