コード例 #1
0
        /// <summary>
        /// Gets current theme info or null if no theme is set
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public static ThemeInfo GetThemeInfo(this HttpContextBase ctx)
        {
            var t = ctx.Get <ThemeInfo>(ThemeInfoKey);

            if (t == null)
            {
                var theme = ctx.GetCurrentThemeName();
                if (!theme.IsNullOrEmpty())
                {
                    t = new ThemeInfo(ctx, theme);
                    ctx.Items[ThemeInfoKey] = t;
                }
            }
            return(t);
        }
コード例 #2
0
        /// <summary>
        /// Helper method to allow easier use of string resources
        /// </summary>
        /// <param name="key">The key. This is also the default value of the resource if the name is not specified</param>
        /// <param name="context">HttpContextBase used to resolve the provider</param>
        /// <param name="defaultValue">Optionally specify the default value of the resource, if it differs from the key</param>
        /// <returns></returns>
        public static string AsResource(this string key, HttpContextBase context, string defaultValue = null)
        {
            var provider = context.Get <IStringResourceProvider>();

            return(GetValue(key, defaultValue, provider));
        }