Пример #1
0
        public T GetValue <T>(string key)
        {
            if (!isInitialized)
            {
                WaitUntilInitialized(TimeSpan.FromSeconds(10));
            }

            if (ConfigCache.TryGetValue(key, out var value))
            {
                if (typeof(T) != typeMap[value.Type])
                {
                    throw new InvalidCastException($"{value.Name} is not type of {value.Type.ToString()}");
                }

                if (value.Type == Enums.ApplicationValueType.Int) //Invalid cast exception long to int düzenlemesi
                {
                    value.Value = Convert.ToInt32(value.Value);
                }
                return((T)value.Value);
            }

            return(default(T));
        }