public string GetHeader(PropertyToken property) { LocalizationKey localizationKey = property.ToLocalizationKey(); return(_localeCache .Retrieve(localizationKey, () => _missingHandler.FindMissingProperty(property, _localeCache.Culture))); }
public string GetTextForKey(StringToken key) { LocalizationKey localizationKey = key.ToLocalizationKey(); return(_localeCache .Retrieve(localizationKey, () => _missingHandler.FindMissingText(key, _localeCache.Culture))); }
public bool Equals(LocalizationKey other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return string.Equals(_key1, other._key1, StringComparison.OrdinalIgnoreCase) && string.Equals(_key2, other._key2, StringComparison.OrdinalIgnoreCase); }
public string Retrieve(LocalizationKey key, Func <string> missing) { var text = initialRead(key); if (text == null) { text = missing(); Append(key, text); } return(text); }
public string Retrieve(LocalizationKey key, Func<string> missing) { var text = initialRead(key); if (text == null) { text = missing(); Append(key, text); } return text; }
private string initialRead(LocalizationKey key) { _lock.EnterReadLock(); try { return(!_data.ContainsKey(key) ? null : _data[key]); } finally { _lock.ExitReadLock(); } }
public void Append(LocalizationKey key, string value) { _lock.Write(() => { if (_data.ContainsKey(key)) { _data[key] = value; } else { _data.Add(key, value); } }); }
public bool Equals(LocalizationKey other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(_key1, other._key1, StringComparison.OrdinalIgnoreCase) && string.Equals(_key2, other._key2, StringComparison.OrdinalIgnoreCase)); }
public ThreadSafeLocaleCache(CultureInfo culture, IEnumerable <LocalString> strings) { _data = new Dictionary <LocalizationKey, string>(); strings.Each(s => { var localizationKey = new LocalizationKey(s.value); if (_data.ContainsKey(localizationKey)) { throw new ArgumentException("Could not add localization key '{0}' to the cache as it already exists.".ToFormat(s.value)); } _data.Add(localizationKey, s.display); }); _culture = culture; }
public ThreadSafeLocaleCache(CultureInfo culture, IEnumerable<LocalString> strings) { _data = new Dictionary<LocalizationKey, string>(); strings.Each(s => { var localizationKey = new LocalizationKey(s.value); if (_data.ContainsKey(localizationKey)) { throw new ArgumentException("Could not add localization key '{0}' to the cache as it already exists.".ToFormat(s.value)); } _data.Add(localizationKey, s.display); }); _culture = culture; }
public void Append(LocalizationKey key, string value) { _lock.EnterWriteLock(); try { if (_data.ContainsKey(key)) { _data[key] = value; } else { _data.Add(key, value); } } finally { _lock.ExitWriteLock(); } }
private string initialRead(LocalizationKey key) { return(_lock.Read(() => !_data.ContainsKey(key) ? null : _data[key])); }
private string initialRead(LocalizationKey key) { return _lock.Read(() => !_data.ContainsKey(key) ? null : _data[key]); }