/// <summary>
        /// 初始化一个<see cref="GitHub_AccessToken_RequestEntity"/>类型的实例
        /// </summary>
        static GitHub_AccessToken_RequestEntity()
        {
            var provider = Ioc.Create <IGitHubConfigProvider>();

            provider.CheckNotNull(nameof(provider));
            GitHubConfig = provider.GetConfigAsync().Result;
        }
Beispiel #2
0
 public ClientFactory(
     ILogger <ClientFactory> logger,
     IOptions <ConfigRoot> options
     )
 {
     _logger      = logger;
     this._config = options.Value.GitHub ?? throw new ConfigurationException(nameof(ConfigRoot.GitHub));
 }
        public void Construct(PathTuple <ModConfig> mod)
        {
            _modTuple = mod;
            string path = GitHubConfig.GetFilePath(GetModDirectory(mod));

            _githubConfig = IConfig <GitHubConfig> .FromPath(path);

            _githubUserConfig = IConfig <GitHubUserConfig> .FromPath(path);
        }
        private async Task <IReadOnlyList <Release> > GetReleases(GitHubConfig configuration)
        {
            try
            {
                var releases = await GitHubClient.Repository.Release.GetAll(configuration.UserName, configuration.RepositoryName);

                ValidRateLimit = false;
                if (!_githubUserConfig.EnablePrereleases)
                {
                    releases = releases.Where(x => x.Prerelease == false).ToList();
                }

                return(releases);
            }
            catch { return(null); }
        }
        public bool IsCompatible(PathTuple <ModConfig> mod)
        {
            try
            {
                if (Task.Run(AssertGitHubOK).Result)
                {
                    string path = GitHubConfig.GetFilePath(GetModDirectory(mod));

                    if (File.Exists(path) && AllowedMods.Contains(mod.Config))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception) { }

            return(false);
        }
        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();
            }
        }
Beispiel #7
0
 public FollowerRepository(GitHubConfig config)
 {
     _config = config ?? throw new ArgumentNullException("config");
 }