コード例 #1
0
        public static MvcHtmlString Script(this HtmlHelper helper, ScriptRef scriptReference, bool throwException = false)
        {
            if (ResourceHelper.TryConfigureScriptManager(scriptReference))
                return MvcHtmlString.Empty;

            var resourceKey = scriptReference.ToString();
            var context = helper.ViewContext.HttpContext;
            var resourceUrl = ResourceHelper.GetWebResourceUrl(scriptReference);

            if (string.IsNullOrEmpty(resourceUrl))
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Script reference for {0} is not found.", resourceKey));

            return ResourceHelper.RegisterResource(context, resourceKey, resourceUrl, throwException);
        }
コード例 #2
0
        public static MvcHtmlString Script(this HtmlHelper helper, ScriptRef scriptReference, bool throwException = false)
        {
            if (ResourceHelper.TryConfigureScriptManager(scriptReference))
                return MvcHtmlString.Empty;

            var resourceKey = scriptReference.ToString();
            var context = helper.ViewContext.HttpContext;
            var resourceUrl = ResourceHelper.GetWebResourceUrl(scriptReference);

            if (string.IsNullOrEmpty(resourceUrl))
                return MvcHtmlString.Empty;

            return ResourceHelper.RegisterResource(context, resourceKey, resourceUrl, throwException);
        }
コード例 #3
0
ファイル: ResourceHelper.cs プロジェクト: virajs/feather
        public static System.Web.Mvc.MvcHtmlString Script(this HtmlHelper helper, ScriptRef scriptReference, bool throwException = false)
        {
            if (ResourceHelper.TryConfigureScriptManager(scriptReference))
            {
                return(System.Web.Mvc.MvcHtmlString.Empty);
            }

            var resourceKey = scriptReference.ToString();
            var context     = helper.ViewContext.HttpContext;
            var resourceUrl = ResourceHelper.GetWebResourceUrl(scriptReference);

            if (string.IsNullOrEmpty(resourceUrl))
            {
                return(System.Web.Mvc.MvcHtmlString.Empty);
            }

            return(ResourceHelper.RegisterResource(context, resourceKey, resourceUrl, throwException));
        }
コード例 #4
0
        public static MvcHtmlString Script(this HtmlHelper helper, ScriptRef scriptReference, bool throwException = false)
        {
            if (ResourceHelper.TryConfigureScriptManager(scriptReference))
            {
                return(MvcHtmlString.Empty);
            }

            var resourceKey = scriptReference.ToString();
            var context     = helper.ViewContext.HttpContext;
            var resourceUrl = ResourceHelper.GetWebResourceUrl(scriptReference);

            if (string.IsNullOrEmpty(resourceUrl))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Script reference for {0} is not found.", resourceKey));
            }

            return(ResourceHelper.RegisterResource(context, resourceKey, resourceUrl, throwException));
        }
コード例 #5
0
        public static string GetWebResourceUrl(ScriptRef scriptReference)
        {
            var    config       = Config.Get <PagesConfig>().ScriptManager;
            var    scriptConfig = config.ScriptReferences[scriptReference.ToString()];
            string resourceUrl  = string.Empty;

            if (config.EnableCdn || (scriptConfig.EnableCdn.HasValue && scriptConfig.EnableCdn.Value))
            {
                resourceUrl = scriptConfig.Path;
            }
            else
            {
                var page = HttpContext.Current.Handler.GetPageHandler() ?? new PageProxy(null);

                resourceUrl = page.ClientScript.GetWebResourceUrl(
                    TypeResolutionService.ResolveType("Telerik.Sitefinity.Resources.Reference"),
                    scriptConfig.Name);
            }

            return(resourceUrl);
        }
コード例 #6
0
ファイル: ResourceHelper.cs プロジェクト: RifasRazick/feather
        public static string GetWebResourceUrl(ScriptRef scriptReference)
        {
            var config = Config.Get<PagesConfig>().ScriptManager;
            var scriptConfig = config.ScriptReferences[scriptReference.ToString()];
            string resourceUrl = string.Empty;

            if (config.EnableCdn || (scriptConfig.EnableCdn.HasValue && scriptConfig.EnableCdn.Value))
            {
                resourceUrl = scriptConfig.Path;
            }
            else
            {
                var page = HttpContext.Current.Handler.GetPageHandler() ?? new PageProxy(null);

                resourceUrl = page.ClientScript.GetWebResourceUrl(
                    TypeResolutionService.ResolveType("Telerik.Sitefinity.Resources.Reference"),
                    scriptConfig.Name);
            }

            return resourceUrl;
        }