예제 #1
0
        private string AdjustForUsageAndContext(CapitalizationContextUsage usage, string name)
        {
            if (name != null && name.Length > 0 && UChar.IsLower(name.CodePointAt(0)) &&
                (displayContextOptions.Capitalization == Capitalization.BeginningOfSentence ||
                 (capitalizationUsage != null && capitalizationUsage[(int)usage])))
            {
                // Note, won't have capitalizationUsage != null && capitalizationUsage[usage.ordinal()]
                // unless capitalization is CAPITALIZATION_FOR_UI_LIST_OR_MENU or CAPITALIZATION_FOR_STANDALONE

                // should only happen when deserializing, etc.
                LazyInitializer.EnsureInitialized(ref capitalizationBrkIter, () => BreakIterator.GetSentenceInstance(locale));
                return(UChar.ToTitleCase(locale, name, capitalizationBrkIter,
                                         UChar.TitleCaseNoLowerCase | UChar.TitleCaseNoBreakAdjustment));
            }
            return(name);
        }
예제 #2
0
 private string AdjustForUsageAndContext(CapitalizationContextUsage usage, String name)
 {
     if (name != null && name.Length > 0 && UCharacter.IsLowerCase(name.CodePointAt(0)) &&
         (capitalization == DisplayContext.CapitalizationForBeginningOfSentence ||
          (capitalizationUsage != null && capitalizationUsage[(int)usage])))
     {
         // Note, won't have capitalizationUsage != null && capitalizationUsage[usage.ordinal()]
         // unless capitalization is CAPITALIZATION_FOR_UI_LIST_OR_MENU or CAPITALIZATION_FOR_STANDALONE
         lock (this)
         {
             if (capitalizationBrkIter == null)
             {
                 // should only happen when deserializing, etc.
                 capitalizationBrkIter = BreakIterator.GetSentenceInstance(locale);
             }
             return(UCharacter.ToTitleCase(locale, name, capitalizationBrkIter,
                                           UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT));
         }
     }
     return(name);
 }