Exemplo n.º 1
0
 internal VersionCheckTask(KMod.Mod mod, IModVersionChecker method,
                           ConcurrentDictionary <string, ModVersionCheckResults> results)
 {
     this.mod     = mod ?? throw new ArgumentNullException(nameof(mod));
     this.method  = method ?? throw new ArgumentNullException(nameof(method));
     this.results = results ?? throw new ArgumentNullException(nameof(results));
     Next         = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Registers the specified mod for automatic version checking. Mods will be registered
        /// using their static ID, so to avoid the default ID from being used instead, set this
        /// attribute in mod.yaml.
        ///
        /// The same mod can be registered multiple times with different methods to check the
        /// mod versions. The methods will be attempted in order from first registered to last.
        /// However, the same mod must not be registered multiple times in different instances
        /// of PVersionCheck.
        /// </summary>
        /// <param name="mod">The mod instance to check.</param>
        /// <param name="checker">The method to use for checking the mod version.</param>
        public void Register(KMod.UserMod2 mod, IModVersionChecker checker)
        {
            var kmod = mod?.mod;

            if (kmod == null)
            {
                throw new ArgumentNullException(nameof(mod));
            }
            if (checker == null)
            {
                throw new ArgumentNullException(nameof(checker));
            }
            RegisterForForwarding();
            string staticID = kmod.staticID;

            if (!checkVersions.TryGetValue(staticID, out VersionCheckMethods checkers))
            {
                checkVersions.Add(staticID, checkers = new VersionCheckMethods(kmod));
            }
            checkers.Methods.Add(checker);
        }