using System.Collections.Generic; using System.Globalization; namespace ScreenConnect; public abstract class ResourceManagerEx : ResourceManagerExBase { private object syncLock = new object(); private State state; protected bool IsRefreshingState { get; private set; } public abstract ICollection LoadResourcePacks(); private State GetState() { State state = this.state; if (state == null) { lock (syncLock) { if (this.state == null) { try { IsRefreshingState = true; this.state = CreateState(LoadResourcePacks()); OnStateRefreshed(); } finally { IsRefreshingState = false; } } state = this.state; } } return state; } protected void InvalidateState() { lock (syncLock) { state = null; } } public IEnumerable> GetAllEntries() { return GetAllEntries(GetState()); } public IEnumerable>>> GetMappedEntries() { return GetMappedEntries(GetState()); } public string GetString(string key, bool returnKeyAsStringIfNonExistent = true) { return GetString(GetState(), key, returnKeyAsStringIfNonExistent); } public string TryFormatString(string key, params object[] parameters) { return TryFormatString(GetState(), key, parameters); } public string TryFormatStringWithFallback(string keyFormat, object[] keyFormatArgs, bool fallbackToKeyOrEmpty, params object[] resourceParameters) { return TryFormatStringWithFallback(GetState(), keyFormat, keyFormatArgs, fallbackToKeyOrEmpty, resourceParameters); } public byte[] GetBytes(string key) { return GetBytes(GetState(), key); } public bool GetBoolean(string key) { return GetBoolean(GetState(), key); } public double GetDouble(string key) { return GetDouble(GetState(), key); } public long GetInt64(string key) { return GetInt64(GetState(), key); } public object GetObject(string key) { return GetObject(GetState(), key); } public object GetObject(string key, CultureInfo cultureInfo) { return GetObject(GetState(), key, cultureInfo); } }