예제 #1
0
        protected void ValidateResourceLangCodes(IEnumerable <string> langCodes, Func <IEnumerable <string>, LocalizedString> invalidLangCodesExceptionMessageBuilder, Func <IEnumerable <string>, LocalizedString> nonUniqueLangCodesExceptionMessageBuilder)
        {
            ExAssert.RetailAssert(langCodes != null, "The langcode(s) passed to ValidateResourceLangCodes must not be null!");
            ExAssert.RetailAssert(invalidLangCodesExceptionMessageBuilder != null, "The invalid langcode(s) exception message builder passed to ValidateResourceLangCodes must not be null!");
            ExAssert.RetailAssert(nonUniqueLangCodesExceptionMessageBuilder != null, "The non-unique langcode(s) exception message builder passed to ValidateResourceLangCodes must not be null!");
            IList <string> list;
            IList <string> list2;

            if (!LocalizedInfoValidator.ValidateResourceLangCodes(langCodes, out list, out list2))
            {
                if (list.Count > 0)
                {
                    LocalizedString localizedExceptionMessage = invalidLangCodesExceptionMessageBuilder(from invalidLangCode in list
                                                                                                        select string.Format("\"{0}\"", invalidLangCode));
                    throw ClassificationDefinitionUtils.PopulateExceptionSource <LocalizedException, IList <string> >(this.CreateInvalidLangCodeException(localizedExceptionMessage), list);
                }
                if (list2.Count > 0)
                {
                    LocalizedString localizedExceptionMessage2 = nonUniqueLangCodesExceptionMessageBuilder(list2);
                    throw ClassificationDefinitionUtils.PopulateExceptionSource <LocalizedException, IList <string> >(this.CreateNonUniqueLangCodeException(localizedExceptionMessage2), list2);
                }
            }
        }
예제 #2
0
 protected virtual LocalizedException CreateNonUniqueLangCodeException(LocalizedString localizedExceptionMessage)
 {
     return(LocalizedInfoValidator.CreateDefaultValidationException(localizedExceptionMessage));
 }