コード例 #1
0
        internal IReadOnlyList <TranslationUnit> GetQuestionSubgroupTranslationUnits(Question question, LocalizableStringType type)
        {
            switch (type)
            {
            case LocalizableStringType.Alternate:
            case LocalizableStringType.Answer:
            case LocalizableStringType.Note:
                UIDataString key = new UIQuestionDataString(question, true, false);
                return(Localizations.FindQuestionGroup(key)?.GetQuestionSubGroup(type)?.TranslationUnits);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
        internal TranslationUnit GetTranslationUnit(UIDataString key)
        {
            switch (key.Type)
            {
            case LocalizableStringType.Category:
                return(Localizations.Categories.TranslationUnits.FirstOrDefault(tu => tu.English == key.SourceUIString));

            case LocalizableStringType.SectionHeading:
                return(Localizations.Groups.FirstOrDefault(g => g.Id == FileBody.GetSectionId(key))?.TranslationUnits.Single());

            case LocalizableStringType.Question:
                return(Localizations.FindQuestionGroup(key)?.TranslationUnits.Single());

            case LocalizableStringType.Alternate:
            case LocalizableStringType.Answer:
            case LocalizableStringType.Note:
                return(Localizations.FindQuestionGroup(key)?.GetQuestionSubGroup(key.Type)?.TranslationUnits.SingleOrDefault(tu => tu.English == key.SourceUIString));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #3
0
        internal TranslationUnit GetLocalizableStringInfo(UIDataString key)
        {
            if (String.IsNullOrWhiteSpace(key?.SourceUIString))
            {
                return(null);
            }

            if (key.Type == LocalizableStringType.Category)
            {
                return(Localizations.Categories.TranslationUnits.SingleOrDefault(tu => tu.English == key.SourceUIString));
            }
            if (key.Type == LocalizableStringType.SectionHeading)
            {
                return(Localizations.Groups.SingleOrDefault(g => g.Id == FileBody.GetSectionId(key))?.TranslationUnits?.Single());
            }

            var question = Localizations.FindQuestionGroup(key);

            if (question == null)
            {
                return(null);
            }
            switch (key.Type)
            {
            case LocalizableStringType.Question:
                return(question.TranslationUnits?.SingleOrDefault());

            case LocalizableStringType.Answer:
            case LocalizableStringType.Note:
            case LocalizableStringType.Alternate:
                return(question.GetQuestionSubGroup(key.Type)?.
                       TranslationUnits.SingleOrDefault(tu => tu.English == key.SourceUIString));

            default:
                throw new Exception("Unhandled type!");
            }
        }