Exemplo n.º 1
0
        private static Dictionary <string, TKeyword> InitializeKeywords <TKeyword>(CultureInfo culture, List <KeyValuePair <TKeyword, LocalizedString> > keywordToLocstringMap, List <KeyValuePair <TKeyword, string> > keywordToCanonicalStringMap)
        {
            Dictionary <string, TKeyword> dictionary = new Dictionary <string, TKeyword>(keywordToLocstringMap.Count + keywordToCanonicalStringMap.Count, StringComparer.Create(culture, true));

            foreach (KeyValuePair <TKeyword, LocalizedString> keyValuePair in keywordToLocstringMap)
            {
                string value = keyValuePair.Value.ToString(culture);
                if (!string.IsNullOrEmpty(value))
                {
                    LocalizedKeywordMapping.AddKeywordToDictionary <TKeyword>(culture, dictionary, keyValuePair.Key, value);
                }
                else if (!culture.TwoLetterISOLanguageName.Equals("en", StringComparison.OrdinalIgnoreCase) && !culture.TwoLetterISOLanguageName.Equals("iv", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentNullException(string.Format("LocalizedString for keyword '{0}' for resource '{1}' in culture '{2}' is null.", keyValuePair.Key, keyValuePair.Value.FullId, culture.Name));
                }
            }
            foreach (KeyValuePair <TKeyword, string> keyValuePair2 in keywordToCanonicalStringMap)
            {
                LocalizedKeywordMapping.AddKeywordToDictionary <TKeyword>(culture, dictionary, keyValuePair2.Key, keyValuePair2.Value);
            }
            return(dictionary);
        }
Exemplo n.º 2
0
        public static LocalizedKeywordMapping GetMapping(CultureInfo culture)
        {
            LocalizedKeywordMapping localizedKeywordMapping;

            lock (LocalizedKeywordMapping.keywordCacheLock)
            {
                if (LocalizedKeywordMapping.mapsByCultures.TryGetValue(culture, out localizedKeywordMapping))
                {
                    return(localizedKeywordMapping);
                }
            }
            localizedKeywordMapping = new LocalizedKeywordMapping(culture);
            lock (LocalizedKeywordMapping.keywordCacheLock)
            {
                LocalizedKeywordMapping result;
                if (LocalizedKeywordMapping.mapsByCultures.TryGetValue(culture, out result))
                {
                    return(result);
                }
                LocalizedKeywordMapping.mapsByCultures.Add(culture, localizedKeywordMapping);
            }
            return(localizedKeywordMapping);
        }
Exemplo n.º 3
0
 private LocalizedKeywordMapping(CultureInfo culture)
 {
     this.propertyKeywordMapping   = LocalizedKeywordMapping.InitializeKeywords <PropertyKeyword>(culture, LocalizedKeywordMapping.propertyKeywordToLocStringMapping, LocalizedKeywordMapping.propertyKeywordToCanonicalStringMapping);
     this.kindKeywordMapping       = LocalizedKeywordMapping.InitializeKeywords <KindKeyword>(culture, LocalizedKeywordMapping.kindKeywordToLocStringMapping, LocalizedKeywordMapping.kindKeywordToCanonicalStringMapping);
     this.importanceKeywordMapping = LocalizedKeywordMapping.InitializeKeywords <Importance>(culture, LocalizedKeywordMapping.importanceToLocStringMapping, LocalizedKeywordMapping.importanceToCanonicalStringMapping);
 }