Example #1
0
        /// <summary>
        /// Every item should start with Rarity in the first line.
        /// This will force the TradeClient to refetch the Public API's data if needed.
        /// </summary>
        public async Task FindAndSetLanguage(string itemDescription)
        {
            var language = AvailableLanguages.Find(x => itemDescription.StartsWith(x.DescriptionRarity));

            if (language != null && SetLanguage(language.Name))
            {
                await initializeService.Initialize();
            }
        }
Example #2
0
        /// <summary>
        /// Every item should start with Rarity in the first line.
        /// This will force the TradeClient to refetch the Public API's data if needed.
        /// </summary>
        public async Task FindAndSetLanguage(string itemDescription)
        {
            if (string.IsNullOrEmpty(itemDescription))
            {
                return;
            }

            var language = AvailableLanguages.Find(x => itemDescription.StartsWith(x.DescriptionRarity));

            if (language != null && SetLanguage(language.Name))
            {
                await cacheService.Clear();

                await initializeService.Initialize();
            }
        }
Example #3
0
        private bool SetLanguage(string name)
        {
            var language = AvailableLanguages.Find(x => x.Name == name);

            if (language == null)
            {
                logger.Information("Couldn't find language matching {language}.", name);
                return(false);
            }

            if (Language == null || Language.DescriptionRarity != language.DescriptionRarity)
            {
                logger.Information("Changed active language support to {language}.", language.Name);
                Language = (ILanguage)Activator.CreateInstance(language.ImplementationType);

                settings.Language_Parser = name;
                settings.Save();

                return(true);
            }

            return(false);
        }