public Task InitializeAsync(IServiceProvider provider) { var confProvider = provider.GetRequiredService <IConfiguration>(); if (Hostname == null) { Hostname = confProvider["httpConfig:defaultHostname"]; } var httpConfSection = confProvider.GetSection("httpConfig"); if (httpConfSection != null) { string uname, pw; if ((uname = httpConfSection.GetSection("authentication")["username"]) != null && (pw = httpConfSection.GetSection("authentication")["password"]) != null) { Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(uname + ':' + pw))); } string usragentheader; if ((usragentheader = httpConfSection["useragent"]) != null) { Client.DefaultRequestHeaders.Add("User-Agent", usragentheader); } } _roundInferenceService = provider.GetService <ICompetitionRoundLogicService>() ?? _roundInferenceService; // optionally, attempt to deduce categories _categoryProvider = provider.GetService <IExternalCategoryProviderService>(); RateLimiter = provider.GetService <IRateLimitProvider>() ?? new NoneRateLimitProvider(); return(Task.CompletedTask); }
public ScoreboardMessageBuilderService(FlagProviderService flagProvider, IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic) { FlagProvider = flagProvider; CompetitionLogic = competitionLogic; #pragma warning disable 0618 // initial assignment, see comments near the property _scoreRetriever = scoreRetriever; #pragma warning restore 0618 }
public ScoreboardMessageBuilderService(IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic, ILocationResolutionService locationResolution) { CompetitionLogic = competitionLogic; LocationResolution = locationResolution; #pragma warning disable 0618 // initial assignment, see comments near the property _scoreRetriever = scoreRetriever; #pragma warning restore 0618 }
public CyberPatriotEventHandlingService(IServiceProvider provider, DiscordSocketClient discord, IDataPersistenceService database, IConfiguration config, ScoreboardMessageBuilderService messageBuilder, IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic, LogService logService) { _discord = discord; _provider = provider; _database = database; _config = config; _messageBuilder = messageBuilder; _scoreRetriever = scoreRetriever; _competitionLogic = competitionLogic; _logService = logService; }
public CyberPatriotEventHandlingService(IServiceProvider provider, DiscordSocketClient discord, IDataPersistenceService database, IConfiguration config, ScoreboardMessageBuilderService messageBuilder, IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic, LogService logService) { _discord = discord; _provider = provider; _database = database; _config = config; _messageBuilder = messageBuilder; _scoreRetriever = scoreRetriever; _competitionLogic = competitionLogic; _logService = logService; _discord.MessageReceived += MessageReceived; _teamUrlRegex = new Regex("https?://" + _config["httpConfig:defaultHostname"].Replace(".", "\\.") + "/team\\.php\\?team=([0-9]{2}-[0-9]{4})"); }
public Task InitializeAsync(IServiceProvider provider, IConfigurationSection httpConfSection) { _httpConfiguration = httpConfSection; if (Hostname == null) { Hostname = httpConfSection["defaultHostname"]; } int forcedCompetitionRound = 0; if (httpConfSection != null) { string uname, pw; if ((uname = httpConfSection.GetSection("authentication")["username"]) != null && (pw = httpConfSection.GetSection("authentication")["password"]) != null) { Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(uname + ':' + pw))); } string usragentheader; if ((usragentheader = httpConfSection["useragent"]) != null) { Client.DefaultRequestHeaders.Add("User-Agent", usragentheader); } forcedCompetitionRound = httpConfSection.GetValue <int>("forceRound"); } _roundInferenceService = provider.GetService <ICompetitionRoundLogicService>() ?? _roundInferenceService; if (forcedCompetitionRound > 0 || _roundInferenceService == null) { _roundInferenceService = new PreconfiguredRoundPassthroughCompetitionRoundLogicService((CompetitionRound)forcedCompetitionRound, _roundInferenceService); } // optionally, attempt to deduce categories _categoryProvider = provider.GetService <IExternalCategoryProviderService>(); RateLimiter = provider.GetService <IRateLimitProvider>() ?? new NoneRateLimitProvider(); return(Task.CompletedTask); }
public PreconfiguredRoundPassthroughCompetitionRoundLogicService(CompetitionRound round, ICompetitionRoundLogicService underlying) { preconfiguredRound = round; underlyingService = underlying; }