public string Get(LocalizationKey key, Func <string> missing)
        {
            var text = InitialRead(key);

            if (text == null)
            {
                text = missing();
            }

            return(text);
        }
        public string TryGetText(LocalizationKey key, CultureInfo culture, object model)
        {
            StringToken token;
            var         isFound = _keyToTokens.Value.TryGetValue(key, out token);

            if (!isFound)
            {
                return(null);
            }

            return(GetText(token, culture, model));
        }
 public void Update(LocalizationKey key, string value)
 {
     _lock.Write(() =>
     {
         if (_data.ContainsKey(key))
         {
             _data[key] = value;
         }
         else
         {
             _data.Add(key, value);
         }
     });
 }
        public ThreadSafeLocaleCache(CultureInfo culture, IEnumerable <LocalString> strings)
        {
            _data = new Dictionary <LocalizationKey, string>();
            strings.Each(s =>
            {
                var localizationKey = new LocalizationKey(s.Key);
                if (_data.ContainsKey(localizationKey))
                {
                    throw new ArgumentException(string.Format("Could not add localization key '{0}' to the cache as it already exists.", s.Key));
                }

                _data.Add(localizationKey, s.Display);
            });

            _culture = culture;
        }
 private string InitialRead(LocalizationKey key)
 {
     return(_lock.Read(() => !_data.ContainsKey(key) ? null : _data[key]));
 }
 public void UpdateText(LocalizationKey key, CultureInfo culture, string value)
 {
     _localeCache[culture].Update(key, value);
 }
 public void UpdateText(LocalizationKey key, CultureInfo culture, string value)
 {
 }
 public string TryGetText(LocalizationKey key, object model)
 {
     return(TryGetText(key, null, model));
 }
 public string TryGetText(LocalizationKey key, CultureInfo culture)
 {
     return(TryGetText(key, culture, null));
 }
 public string TryGetText(LocalizationKey key)
 {
     return(TryGetText(key, null));
 }
 public void UpdateText(LocalizationKey localizationKey, CultureInfo culture, string value)
 {
     _localizationDataProvider.UpdateText(localizationKey, culture, value);
 }
 public static void UpdateText(LocalizationKey key, CultureInfo culture, string value)
 {
     _localizationProvider.UpdateText(key, culture, value);
 }
 public static string TryGetText(LocalizationKey key, CultureInfo culture = null, object model = null)
 {
     return(_localizationProvider.TryGetText(key, culture, model));
 }