コード例 #1
0
        public static AssetsHelper GetInstance(IHtmlHelper htmlHelper)
        {
            var instanceKey = "AssetsHelperInstance";

            var context = htmlHelper.ViewContext.HttpContext;

            if (context == null)
            {
                return(null);
            }

            var assetsHelper = (AssetsHelper)context.Items[instanceKey];

            if (assetsHelper == null)
            {
                context.Items.Add(instanceKey, assetsHelper = new AssetsHelper());
            }

            return(assetsHelper);
        }
コード例 #2
0
 public static AssetsHelper Assets(this IHtmlHelper htmlHelper)
 {
     return(AssetsHelper.GetInstance(htmlHelper));
 }