Example #1
0
        public static TSettings Get <TSettings>(bool cached = true) where TSettings : class, ISettings, new()
        {
            string key = GetSettingKey(typeof(TSettings));

            if (typeof(ISiteSetting).IsAssignableFrom(typeof(TSettings)))
            {
                if (cached)
                {
                    return(SiteStateCache.Deserialize <TSettings>(key));
                }
                else
                {
                    return(JSON.ParseTolerant <TSettings>(IoC.Resolve <ISiteStateService>().Load(key).TrimToNull() ?? "{}"));
                }
            }
            else
            {
                if (cached)
                {
                    return(LocalUserStateCache.Deserialize <TSettings>(key));
                }
                else
                {
                    return(JSON.ParseTolerant <TSettings>(IoC.Resolve <ILocalUserStateService>().Load(key).TrimToNull() ?? "{}"));
                }
            }
        }
Example #2
0
        public static object Get(Type settingType, bool cached = true)
        {
            string key = GetSettingKey(settingType);

            if (typeof(ISiteSetting).IsAssignableFrom(settingType))
            {
                if (cached)
                {
                    return(SiteStateCache.Get(key));
                }
                else
                {
                    return(JSON.ParseTolerant(IoC.Resolve <ISiteStateService>().Load(key).TrimToNull() ?? "{}", settingType));
                }
            }
            else
            {
                if (cached)
                {
                    return(LocalUserStateCache.Get(key));
                }
                else
                {
                    return(JSON.ParseTolerant(IoC.Resolve <ILocalUserStateService>().Load(key).TrimToNull() ?? "{}", settingType));
                }
            }
        }
Example #3
0
 static SiteStateCache()
 {
     _instance    = new SiteStateCache();
     _stringItems = new Dictionary <string, Item>();
     _objectItems = new Dictionary <string, Item>();
 }