public IMod?SearchMod(IModReference modReference, ModSearchOptions modSearchOptions, bool add) { IMod?mod = null; try { if (modSearchOptions.HasFlag(ModSearchOptions.Registered)) { mod = ModsInternal.FirstOrDefault(x => x.Equals(modReference)); if (mod != null) { return(mod); } } if (modSearchOptions.HasFlag(ModSearchOptions.FileSystem)) { throw new NotImplementedException(); } return(mod); } finally { if (mod != null && add) { AddMod(mod); } } }
public JsonModReference(IModReference modReference) { Requires.NotNull(modReference, nameof(modReference)); Identifier = modReference.Identifier; Type = modReference.Type; VersionRangeString = modReference.VersionRange?.ToString(); }
/// <summary> /// Validates an <see cref="IModReference"/> data. Throws an <see cref="ModinfoException"/> when validation failed. /// </summary> /// <remarks> /// When <see cref="IModReference.Type"/> is <see cref="ModType.Workshops"/>: <see cref="IModReference.Identifier"/> must parse into an <see cref="uint"/> /// However the value must also not be 0. /// <br></br> /// The validator will not check for if the <see cref="IModReference.Identifier"/> is a valid relative or absolute path. /// Tools will have to check this themself based on the current operating system and file system. /// </remarks> /// <param name="modReference">The data to check</param> /// <exception cref="ModinfoException">When validation failed.</exception> public static void Validate(this IModReference modReference) { if (string.IsNullOrEmpty(modReference.Identifier)) { throw new ModinfoException("Mod-Reference data is invalid: Identifier is missing."); } switch (modReference.Type) { case ModType.Workshops: ValidateSteamId(modReference.Identifier, "Mod-Reference data is invalid: "); break; case ModType.Default: case ModType.Virtual: break; default: throw new ModinfoException($"ERROR: Unknown ModType! ({modReference.Type})"); } }
public static string GetAbsolutePath(this IModReference modReference, IGame game) { if (modReference is null) { throw new ArgumentNullException(nameof(modReference)); } if (string.IsNullOrEmpty(modReference.Identifier)) { throw new InvalidOperationException("location must not be null or empty"); } if (modReference.Type == ModType.Virtual || modReference.Type == ModType.Workshops) { throw new InvalidOperationException("ModReference must be a ModType of 'Default'"); } if (Path.IsPathRooted(modReference.Identifier)) { return(modReference.Identifier); } if (game is null) { throw new ArgumentNullException(nameof(game)); } return(Path.Combine(game.Directory.FullName, modReference.Identifier)); }
public abstract bool Equals(IModReference other);
public IMod?SearchMod(IModReference modReference, ModSearchOptions modSearchOptions, bool add) { throw new NotImplementedException(); }
public override bool Equals(IModReference other) { throw new NotImplementedException(); }