private static Task <IEnumerable <IRule> > GetRulesAsync(this IRulesContainer rulesContainer) { if (rulesContainer == null) { throw new InvalidCastException($"Supplied command does not implement {nameof(IRulesContainer)} interface."); } return(rulesContainer.GetRulesAsync()); }
public SyncRulesBackgroundService(IDandanplayApi dandanplayApi, IRulesContainer rulesContainer, IConfiguration configuration, ILogger <SyncRulesBackgroundService> logger) { _dandanplayApi = dandanplayApi; _rulesContainer = rulesContainer; _configuration = configuration; _logger = logger; _syncPeriod = int.Parse(configuration["SyncPeriod"]); }
public CheckNewResourcesBackgroundService(IRulesContainer rulesContainer, IResApi resApi, IDownloader downloader, ITorrentService torrentService, IConfiguration configuration, ILogger <CheckNewResourcesBackgroundService> logger) { _rulesContainer = rulesContainer; _resApi = resApi; _downloader = downloader; _torrentService = torrentService; _configuration = configuration; _logger = logger; _checkPeriod = int.Parse(configuration["CheckPeriod"]); }
public bool RuleMatches(IRulesContainer entity, LogicalRuleOperator logicalOperator = LogicalRuleOperator.Or) { Guard.NotNull(entity, nameof(entity)); var ruleSets = entity.RuleSets.Where(x => x.Scope == RuleScope.Cart).ToArray(); if (!ruleSets.Any()) { return(true); } var expressions = ruleSets .Select(x => _ruleFactory.CreateExpressionGroup(x, this)) .Where(x => x != null) .Cast <RuleExpression>() .ToArray(); return(RuleMatches(expressions, logicalOperator)); }
public async Task <bool> RuleMatchesAsync(IRulesContainer entity, LogicalRuleOperator logicalOperator = LogicalRuleOperator.Or) { Guard.NotNull(entity, nameof(entity)); var ruleSets = entity.RuleSets.Where(x => x.Scope == RuleScope.Cart).ToArray(); if (!ruleSets.Any()) { return(true); } var expressions = await ruleSets .SelectAsync(x => _ruleService.CreateExpressionGroupAsync(x, this)) .Where(x => x != null) .Cast <RuleExpression>() .ToArrayAsync(); return(await RuleMatchesAsync(expressions, logicalOperator)); }
public async Task <bool> RuleMatchesAsync(IRulesContainer entity, LogicalRuleOperator logicalOperator = LogicalRuleOperator.Or) { Guard.NotNull(entity, nameof(entity)); var ruleSets = entity.RuleSets.Where(x => x.Scope == RuleScope.Cart).ToArray(); if (!ruleSets.Any()) { return(true); } // TODO: (mg) (core) Complete CartRuleProvider (IRuleFactory required). var expressions = ruleSets //.Select(x => _ruleFactory.CreateExpressionGroup(x, this)) //.Where(x => x != null) .Cast <RuleExpression>() .ToArray(); return(await RuleMatchesAsync(expressions, logicalOperator)); }
public ServerController(IRulesContainer rulesContainer, IConfiguration configuration, ILogger <ServerController> logger) { _rulesContainer = rulesContainer; _configuration = configuration; _logger = logger; }