Exemplo n.º 1
0
        public async Task <Models.TranslationResult> ExecuteSearchAsync(string word, Models.Dictionary dictionary)
        {
            int start = 0;

            Models.TranslationResult result = await ExecutePageSearchAsync(word, dictionary, start);

            Models.TranslationResult temporaryResult = null;
            bool loadAllTranslations = _featureToggleService.LoadAllTranslations();

            do
            {
                start          += 100;
                temporaryResult = await ExecutePageSearchAsync(word, dictionary, start);

                if (temporaryResult == null)
                {
                    break;
                }

                if (temporaryResult.PrimaryTranslations.Any())
                {
                    result.PrimaryTranslations.AddRange(temporaryResult.PrimaryTranslations);
                }

                if (temporaryResult.AdditionalTranslations.Any())
                {
                    result.AdditionalTranslations.AddRange(temporaryResult.AdditionalTranslations);
                }

                if (temporaryResult.CompoundForms.Any())
                {
                    result.CompoundForms.AddRange(temporaryResult.CompoundForms);
                }

                if (!loadAllTranslations)
                {
                    break;
                }
            } while (temporaryResult.CompoundForms.Any() || temporaryResult.AdditionalTranslations.Any() || temporaryResult.PrimaryTranslations.Any());

            return(result);
        }