private static void Register(this HttpContextBase context, HtmlResource resource) { var rs = context.Items["HtmlResources"] as List <HtmlResource>; if (rs == null) { rs = new List <HtmlResource>(); context.Items["HtmlResources"] = rs; } if (rs.Contains(resource)) { return; } rs.Add(resource); }
/// <summary> /// Register resource to be rendered on this page /// </summary> /// <param name="controller"></param> /// <param name="resource"></param> public static void Register(this ControllerBase controller, HtmlResource resource) { Register(controller.ControllerContext.HttpContext, resource); }
/// <summary> /// Register resource to be rendered on this page /// </summary> /// <param name="helper"></param> /// <param name="resource"></param> public static void Register(this HtmlHelper helper, HtmlResource resource) { Register(helper.ViewContext.HttpContext, resource); }