Ejemplo n.º 1
0
 public void Warn(string msg)
 {
     _logger.Warn <CdfLogger>(msg);
 }
 public void Warn(Type reporting, string message) => _logger.Warn(reporting, message);
Ejemplo n.º 3
0
        /// <summary>
        /// Returns all key/values in storage for the given culture
        /// </summary>
        /// <returns></returns>
        public IDictionary <string, string> GetAllStoredValues(CultureInfo culture)
        {
            if (culture == null)
            {
                throw new ArgumentNullException("culture");
            }

            // TODO: Hack, see notes on ConvertToSupportedCultureWithRegionCode
            culture = ConvertToSupportedCultureWithRegionCode(culture);

            var result = new Dictionary <string, string>();

            var xmlSource = _xmlSource ?? (_fileSources != null
                ? _fileSources.Value.GetXmlSources()
                : null);

            if (xmlSource != null)
            {
                if (xmlSource.ContainsKey(culture) == false)
                {
                    _logger.Warn <OldLocalizedTextService>("The culture specified {Culture} was not found in any configured sources for this service", culture);
                    return(result);
                }

                //convert all areas + keys to a single key with a '/'
                result = GetStoredTranslations(xmlSource, culture);

                //merge with the English file in case there's keys in there that don't exist in the local file
                var englishCulture = new CultureInfo("en-US");
                if (culture.Equals(englishCulture) == false)
                {
                    var englishResults = GetStoredTranslations(xmlSource, englishCulture);
                    foreach (var englishResult in englishResults.Where(englishResult => result.ContainsKey(englishResult.Key) == false))
                    {
                        result.Add(englishResult.Key, englishResult.Value);
                    }
                }
            }
            else
            {
                if (_dictionarySource.ContainsKey(culture) == false)
                {
                    _logger.Warn <OldLocalizedTextService>("The culture specified {Culture} was not found in any configured sources for this service", culture);
                    return(result);
                }

                //convert all areas + keys to a single key with a '/'
                foreach (var area in _dictionarySource[culture])
                {
                    foreach (var key in area.Value)
                    {
                        var dictionaryKey = string.Format("{0}/{1}", area.Key, key.Key);
                        //i don't think it's possible to have duplicates because we're dealing with a dictionary in the first place, but we'll double check here just in case.
                        if (result.ContainsKey(dictionaryKey) == false)
                        {
                            result.Add(dictionaryKey, key.Value);
                        }
                    }
                }
            }

            return(result);
        }