System.Web.Mvc.AssetsHelper.GetInstance C# (CSharp) Method

GetInstance() public static method

public static GetInstance ( HtmlHelper htmlHelper ) : AssetsHelper
htmlHelper HtmlHelper
return AssetsHelper
        public static AssetsHelper GetInstance(HtmlHelper htmlHelper)
        {
            var instanceKey = "48F2764A-6898-450E-99F8-1EF0B912ED03";

            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;
        }

Usage Example

Example #1
0
 public static AssetsHelper Assets(this HtmlHelper htmlHelper)
 {
     return(AssetsHelper.GetInstance(htmlHelper));
 }