public void Construct(PathGenericTuple <ModConfig> mod) { _modTuple = mod; string path = GithubConfig.GetFilePath(GetModDirectory(mod)); _githubConfig = GithubConfig.FromPath(path); _githubUserConfig = GithubUserConfig.FromPath(path); }
/* Helper classes */ private static void MakeTimestampsIfNotExist(IEnumerable <PathGenericTuple <ModConfig> > mods) { foreach (var modWithConfig in mods) { var configPath = GithubUserConfig.GetFilePath(GetModDirectory(modWithConfig)); if (!File.Exists(configPath)) { 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 => GithubUserConfig.FromPath(GithubUserConfig.GetFilePath(GetModDirectory(x))).LastCheckTimestamp); var allowedMods = orderedModsWithConfigs.Take(UnregisteredRateLimit).Select(x => x.Object); AllowedMods = new HashSet <ModConfig>(allowedMods); } catch (Exception) { Debugger.Break(); } }
public void PostUpdateCallback(bool hasUpdates) { _githubUserConfig.LastCheckTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds(); GithubUserConfig.ToPath(_githubUserConfig, GithubUserConfig.GetFilePath(GetModDirectory(_modTuple))); }