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


C# HttpServerUtility.RelativePath方法代码示例

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


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

示例1: RegisterBundle

        private void RegisterBundle(HttpServerUtility server, string bundle,
            BundleType type,
            params string[] files)
        {
            if (string.IsNullOrWhiteSpace(bundle))
            throw new ArgumentNullException("bundle", "Cannot register an empty bundle");
              var compressor = GetCompressor(type);
              if (compressor.Cache.ContainsKey(bundle))
            throw new ArgumentException("Bundle already registered");
              if (files == null || files.Length == 0)
            throw new ArgumentNullException("files", "No files to register");

              var list = files.ToList();
              if (server != null)
            list = list.ConvertAll(file => server.MapPath(file));

              if (RaiseErrorIfFileDoesNotExists)
              {
            var notFound = list.ToList().FindAll(file => !File.Exists(file));
            if (notFound != null && notFound.Count > 0)
              throw new ArgumentException(string.Format("Not able to find following files: {0}{1}", Environment.NewLine, string.Join(Environment.NewLine, notFound)));
              }

              if (IsDevMode)
            compressor.Cache.Add(bundle, string.Join(Environment.NewLine, files.ToList().ConvertAll(path => string.Format(compressor.Tag, ResolvePath(path)))));
              else
              {
            StringBuilder sb = new StringBuilder();
            var yuiCompressor = compressor.GetCompressor();

            list.ToList().ForEach(file =>
            {
              if (RaiseErrorIfFileDoesNotExists || (!RaiseErrorIfFileDoesNotExists && File.Exists(file)))
            sb.Append(yuiCompressor.Compress(File.ReadAllText(file)));
            });

            if (imageCache.Count > 0)
              imageCache.Keys.ToList().ForEach(key => sb.Replace(key, imageCache[key]));

            var content = sb.ToString();
            content = yuiCompressor.Compress(content); // double compression

            var format = AddHash ? "{0}." + CreateHash(content) + ".{1}" : "{0}.{1}";
            var path = Path.Combine(server.MapPath(compressor.Folder), string.Format(format, bundle, compressor.Extension));
            WriteContent(path, content);

            path = ResolvePath(server.RelativePath(path));
            compressor.Cache.Add(bundle, string.Format(compressor.Tag, path));
              }
        }
开发者ID:pushkaraditya,项目名称:bundleandminify,代码行数:50,代码来源:Manager.cs


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