public void Construct(PathTuple <ModConfig> mod) { _modTuple = mod; string path = GitHubConfig.GetFilePath(GetModDirectory(mod)); _githubConfig = IConfig <GitHubConfig> .FromPath(path); _githubUserConfig = IConfig <GitHubUserConfig> .FromPath(path); }
/* Helper classes */ private static void MakeTimestampsIfNotExist(IEnumerable <PathTuple <ModConfig> > mods) { foreach (var modWithConfig in mods) { var configPath = GitHubUserConfig.GetFilePath(GetModDirectory(modWithConfig)); if (!File.Exists(configPath)) { IConfig <GitHubUserConfig> .ToPath(new GitHubUserConfig(0), configPath); } } }
static GitHubLatestUpdateResolver() { try { GitHubClient = new GitHubClient(new ProductHeaderValue("Reloaded-II")); // Get list of mods allowed to be updated this time around. var allMods = ModConfig.GetAllMods(); var allModsWithConfigs = allMods.Where(x => File.Exists(GitHubConfig.GetFilePath(GetModDirectory(x)))); MakeTimestampsIfNotExist(allModsWithConfigs); var orderedModsWithConfigs = allModsWithConfigs.OrderBy(x => IConfig <GitHubUserConfig> .FromPath(GitHubUserConfig.GetFilePath(GetModDirectory(x))).LastCheckTimestamp); var allowedMods = orderedModsWithConfigs.Take(UnregisteredRateLimit).Select(x => x.Config); AllowedMods = new HashSet <ModConfig>(allowedMods); } catch (Exception) { Debugger.Break(); } }
public void PostUpdateCallback(bool hasUpdates) { _githubUserConfig.LastCheckTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); IConfig <GitHubUserConfig> .ToPath(_githubUserConfig, GitHubUserConfig.GetFilePath(GetModDirectory(_modTuple))); }