Ejemplo n.º 1
0
 public TransferController(ILogger <TransferController> logger, IRulesRepository rulesRepository, IRulesCache rulesCache, IRulesManager rulesManager, IFlowManager flowManager)
 {
     _logger            = logger;
     _rulesRepository   = rulesRepository;
     this._rulesCache   = rulesCache;
     this._rulesManager = rulesManager;
     this._flowManager  = flowManager;
 }
Ejemplo n.º 2
0
        public async Task LoadSelectedModules(List <string> modules)
        {
            if (this._rulesCache == null)
            {
                throw new InvalidOperationException(Properties.Resources.rulesCacheCannotBeNull);
            }

            if (modules.Count < 1)
            {
                return;
            }

            List <string> queryItems = modules.Select(item => string.Concat(item, PIPE, this._applicationOptions.ApplicationName)).ToList();
            ICollection <RulesModuleModel> rulesModules = (await this._repository.GetItemsAsync <RulesModuleModel, RulesModule>(item => queryItems.Contains(item.NamePlusApplication)));

            this._rulesCache = rulesModules.Aggregate(this._rulesCache, (cache, next) =>
            {
                string moduleName = next.Name.ToLowerInvariant();
                lock (cache)
                {
                    RuleSet ruleSet = next.DeserializeRuleSetFile();
                    if (ruleSet == null)
                    {
                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.invalidRulesetFormat, moduleName));
                    }

                    if (cache.RuleEngines.ContainsKey(moduleName))
                    {
                        cache.RuleEngines[moduleName] = new RuleEngine(ruleSet, RulesSerializer.GetValidation(ruleSet));
                    }
                    else
                    {
                        cache.RuleEngines.Add(moduleName, new RuleEngine(ruleSet, RulesSerializer.GetValidation(ruleSet)));
                    }

                    using (IResourceReader reader = new ResourceReader(new MemoryStream(next.ResourceSetFile)))
                    {
                        reader.OfType <DictionaryEntry>()
                        .ToList()
                        .ForEach(entry =>
                        {
                            string resourceKey = (string)entry.Key;
                            if (cache.ResourceStrings.ContainsKey(resourceKey))
                            {
                                cache.ResourceStrings[resourceKey] = (string)entry.Value;
                            }
                            else
                            {
                                cache.ResourceStrings.Add(resourceKey, (string)entry.Value);
                            }
                        });
                    }
                }

                return(cache);
            });
        }
Ejemplo n.º 3
0
        public async Task AddRulesCacheService()
        {
            IRulesCache cache = await LoadRules(rulesLoader);

            App.ServiceCollection.AddSingleton <IRulesCache>(sp =>
            {
                return(cache);
            });
        }
Ejemplo n.º 4
0
        private async void DismissedEventHandler(SplashScreen sender, object args)
        {
            dismissed = true;

            (Application.Current as App).ServiceProvider = await GetServiceProvider(new ServiceCollection());


            IRulesCache cache = (Application.Current as App).ServiceProvider.GetRequiredService <IRulesCache>();

            UiNotificationService uiNotificationService = (Application.Current as App).ServiceProvider.GetRequiredService <UiNotificationService>();

            GetSelectedVoice(uiNotificationService, ApplicationData.Current.RoamingSettings);
            uiNotificationService.HasAdFree = await StoreAccessHelper.Instance.CheckIfUserHasAdFreeSubscriptionAsync();

            DismissExtendedSplash();
        }
Ejemplo n.º 5
0
 public DirectorFactory(IRulesCache rulesCache)
 {
     this._rulesCache = rulesCache;
 }
Ejemplo n.º 6
0
 public Director(IFlowManager flowManager, IRulesCache rulesCache)
 {
     this.flowManager = flowManager;
     this.rulesCache  = rulesCache;
 }
Ejemplo n.º 7
0
 public RulesManager(IRulesRepository repository, IOptions <ApplicationOptions> optionsAccessor, IRulesCache rulesCache)
 {
     this._repository         = repository;
     this._applicationOptions = optionsAccessor.Value;
     this._rulesCache         = rulesCache;
 }