当前位置: 首页>>代码示例>>C#>>正文


C# HttpContextBase.IsAbsolutePath方法代码示例

本文整理汇总了C#中System.Web.HttpContextBase.IsAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextBase.IsAbsolutePath方法的具体用法?C# HttpContextBase.IsAbsolutePath怎么用?C# HttpContextBase.IsAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpContextBase的用法示例。


在下文中一共展示了HttpContextBase.IsAbsolutePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteStaggeredDependencies

        /// <summary>
        /// Because we can have both internal and external dependencies rendered, we need to stagger the script tag output... if they are external, we need to stop the compressing/combining
        /// and write out the external dependency, then resume the compressing/combining handler.
        /// </summary>
        /// <param name="dependencies"></param>
        /// <param name="http"></param>
        /// <param name="builder"></param>
        /// <param name="renderCompositeFiles"></param>
        /// <param name="renderSingle"></param>
        protected void WriteStaggeredDependencies(
            IEnumerable<IClientDependencyFile> dependencies, 
            HttpContextBase http, 
            StringBuilder builder,
            Func<IEnumerable<IClientDependencyFile>, HttpContextBase, IDictionary<string, string>, string> renderCompositeFiles,
            Func<string, IDictionary<string, string>, string> renderSingle)
        {


            //This action will stagger the output based on whether or not the html attribute declarations are the same for each dependency
            Action<IEnumerable<IClientDependencyFile>> staggerOnDifferentAttributes = (list) =>
            {
                var sameAttributes = new List<IClientDependencyFile>();
                var currHtmlAttr = GetHtmlAttributes(list.ElementAt(0));
                foreach (var c in list)
                {
                    if (!currHtmlAttr.IsEqualTo(GetHtmlAttributes(c)))
                    {
                        //if the attributes are different we need to stagger
                        if (sameAttributes.Any())
                        {
                            //render the current buffer
                            builder.Append(renderCompositeFiles(sameAttributes, http, currHtmlAttr));
                            //clear the buffer
                            sameAttributes.Clear();
                        }
                    }

                    //add the item to the buffer and set the current html attributes
                    sameAttributes.Add(c);
                    currHtmlAttr = GetHtmlAttributes(c);
                }

                //if there's anything in the buffer then write the remaining
                if (sameAttributes.Any())
                    builder.Append(renderCompositeFiles(sameAttributes, http, currHtmlAttr));
            };

            var currNonRemoteFiles = new List<IClientDependencyFile>();
            foreach (var f in dependencies)
            {
                //if it is an external resource, then we need to break the sequence
                // unless it has been explicitely required that the dependency be bundled
                if (http.IsAbsolutePath(f.FilePath)
                    //remote dependencies aren't local
                    && !new Uri(f.FilePath, UriKind.RelativeOrAbsolute).IsLocalUri(http)
                    // not required to be bundled
                    && !f.ForceBundle)
                {
                    //we've encountered an external dependency, so we need to break the sequence and restart it after
                    //we output the raw script tag
                    if (currNonRemoteFiles.Count > 0)
                    {
                        //render the current buffer
                        staggerOnDifferentAttributes(currNonRemoteFiles);
                        //clear the buffer
                        currNonRemoteFiles.Clear();
                    }
                    //write out the single script tag
                    builder.Append(renderSingle(f.FilePath, GetHtmlAttributes(f)));
                }
                else
                {
                    //its a normal registration, add to the buffer
                    currNonRemoteFiles.Add(f);
                }
            }
            //now check if there's anything in the buffer to render
            if (currNonRemoteFiles.Count > 0)
            {
                //render the current buffer
                staggerOnDifferentAttributes(currNonRemoteFiles);
            }
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:83,代码来源:BaseFileRegistrationProvider.cs

示例2: WriteStaggeredDependencies

        /// <summary>
        /// Because we can have both internal and external dependencies rendered, we need to stagger the script tag output... if they are external, we need to stop the compressing/combining
        /// and write out the external dependency, then resume the compressing/combining handler.
        /// </summary>
        /// <param name="dependencies"></param>
        /// <param name="http"></param>
        /// <param name="builder"></param>
        /// <param name="renderCompositeFiles"></param>
        /// <param name="renderSingle"></param>
        protected void WriteStaggeredDependencies(
            IEnumerable<IClientDependencyFile> dependencies,
            HttpContextBase http,
            StringBuilder builder,
            Func<IEnumerable<IClientDependencyFile>, HttpContextBase, IDictionary<string, string>, string> renderCompositeFiles,
            Func<string, IDictionary<string, string>, string> renderSingle)
        {
            var fileBasedExtensions = ClientDependencySettings.Instance.FileBasedDependencyExtensionList
                                                              .Union(FileWriters.GetRegisteredExtensions())
                                                              .ToArray();

            var currNonRemoteFiles = new List<IClientDependencyFile>();
            foreach (var f in dependencies)
            {
                //need to parse out the request's extensions and remove query strings
                //need to force non-bundled lines for items with query parameters or a hash value.
                var extension = f.FilePath.Contains('?') || f.FilePath.Contains('#') ? "" : Path.GetExtension(f.FilePath);
                var stringExt = "";
                if (!string.IsNullOrWhiteSpace(extension))
                {
                    stringExt = extension.ToUpper().Split(new[] {'?'}, StringSplitOptions.RemoveEmptyEntries)[0];
                }

                // if it is an external resource OR
                // if it is a non-standard JS/CSS resource (i.e. a server request)
                // then we need to break the sequence
                // unless it has been explicitely required that the dependency be bundled
                if (!http.IsAbsolutePath(f.FilePath) && !fileBasedExtensions.Contains(stringExt)
                    //now check for external resources
                    || (http.IsAbsolutePath(f.FilePath)
                        //remote dependencies aren't local
                        && !new Uri(f.FilePath, UriKind.RelativeOrAbsolute).IsLocalUri(http)
                        // not required to be bundled
                        && !f.ForceBundle))
                {
                    //we've encountered an external dependency, so we need to break the sequence and restart it after
                    //we output the raw script tag
                    if (currNonRemoteFiles.Count > 0)
                    {
                        //render the current buffer
                        StaggerOnDifferentAttributes(http, builder, currNonRemoteFiles, renderCompositeFiles);
                        //clear the buffer
                        currNonRemoteFiles.Clear();
                    }
                    //write out the single script tag
                    builder.Append(renderSingle(f.FilePath, GetHtmlAttributes(f)));
                }
                else
                {
                    //its a normal registration, add to the buffer
                    currNonRemoteFiles.Add(f);
                }
            }
            //now check if there's anything in the buffer to render
            if (currNonRemoteFiles.Count > 0)
            {
                //render the current buffer
                StaggerOnDifferentAttributes(http, builder, currNonRemoteFiles, renderCompositeFiles);
            }
        }
开发者ID:korodizs,项目名称:ClientDependency,代码行数:69,代码来源:BaseFileRegistrationProvider.cs


注:本文中的System.Web.HttpContextBase.IsAbsolutePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。