Esempio n. 1
0
        private async Task <CardStyles> GetStyle(string theme)
        {
            if (!File.Exists(ThemeFile))
            {
                return(new CardStyles());
            }

            var styles = _cacheService.Get <IEnumerable <CardStyles> >(CacheKeys.StyleKey);

            if (styles != null)
            {
                return styles.Theme(theme) with {
                }
            }
            ;                                        // Prevent changes at Memory version of CardStyle

            var jsonContent = await File.ReadAllTextAsync(ThemeFile);

            styles = JsonSerializer.Deserialize <IEnumerable <CardStyles> >(jsonContent);

            _cacheService.Set(CacheKeys.StyleKey, styles, TimeSpan.FromDays(30));

            return(styles.Theme(theme) with {
            });