• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BundleResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BundleResponse的典型用法代码示例。如果您正苦于以下问题:C# BundleResponse类的具体用法?C# BundleResponse怎么用?C# BundleResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BundleResponse类属于命名空间,在下文中一共展示了BundleResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Process

        /// <summary>
        /// Processes the specified bundle of LESS files.
        /// </summary>
        /// <param name="context"> </param>
        /// <param name="bundle">The LESS bundle.</param>
        public void Process(BundleContext context, BundleResponse bundle)
        {
            if (bundle == null)
                throw new ArgumentNullException("bundle");

            context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();

            var parser = new Parser();
            var engine = new LessEngine(parser);
            var content = new StringBuilder();
            
            foreach (var file in bundle.Files)
            {
                // set current file path
                SetCurrentFilePath(parser, file.FullName);
                
                var text = File.ReadAllText(file.FullName);
                var css = engine.TransformToCss(text, file.FullName);
                content.AppendLine(css);
                
                // content.Append(engine.TransformToCss(text, file.FullName));
                // content.AppendLine();

                AddFileDependencies(parser);
            }
            
            bundle.Content = content.ToString();
            bundle.ContentType = "text/css";
        }
开发者ID:onebeatconsumer,项目名称:onebeatconsumer.blog,代码行数:34,代码来源:LessTransformer.cs


示例2: Process

        public override void Process(BundleResponse bundle)
        {
            var compiler = new CoffeeScriptEngine();
            bundle.Content = compiler.Compile(bundle.Content);

            base.Process(bundle);
        }
开发者ID:Microsoft-Web,项目名称:HOL-ASPNET45AndVisualStudio2012,代码行数:7,代码来源:CoffeeMinify.cs


示例3: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            var compiler = new HandlebarsCompiler();
            var templates = new Dictionary<string, string>();
            var server = context.HttpContext.Server;

            foreach (var bundleFile in response.Files)
            {
                var filePath = server.MapPath(bundleFile.VirtualFile.VirtualPath);
                var bundleRelativePath = GetRelativePath(server, bundleFile, filePath);
                var templateName = namer.GenerateName(bundleRelativePath, bundleFile.VirtualFile.Name);
                var template = File.ReadAllText(filePath);
                var compiled = compiler.Precompile(template, false);

                templates[templateName] = compiled;
            }
            StringBuilder javascript = new StringBuilder();
            foreach (var templateName in templates.Keys)
            {
                javascript.AppendFormat("Ember.TEMPLATES['{0}']=", templateName);
                javascript.AppendFormat("Ember.Handlebars.template({0});", templates[templateName]);
            }

            var Compressor = new JavaScriptCompressor();
            var compressed = Compressor.Compress(javascript.ToString());

            response.ContentType = "text/javascript";
            response.Cacheability = HttpCacheability.Public;
            response.Content = compressed;
        }
开发者ID:kingpin2k,项目名称:HandlebarsHelper,代码行数:30,代码来源:HandlebarsTransformer.cs


示例4: Process

        public virtual void Process(BundleContext context, BundleResponse response)
        {
            var file = VirtualPathUtility.GetFileName(context.BundleVirtualPath);

            if (!context.BundleCollection.UseCdn)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(ContainerName))
            {
                throw new Exception("ContainerName Not Set");
            }

            var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");

            var conn = CloudStorageAccount.Parse(connectionString);
            var cont = conn.CreateCloudBlobClient().GetContainerReference(ContainerName);
            cont.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
            var blob = cont.GetBlockBlobReference(file);

            blob.Properties.ContentType = response.ContentType;
            blob.UploadText(response.Content);

            var uri = string.IsNullOrWhiteSpace(CdnHost) ? blob.Uri.AbsoluteUri.Replace("http:", "").Replace("https:", "") : string.Format("{0}/{1}/{2}", CdnHost, ContainerName, file);

            using (var hashAlgorithm = CreateHashAlgorithm())
            {
                var hash = HttpServerUtility.UrlTokenEncode(hashAlgorithm.ComputeHash(Encoding.Unicode.GetBytes(response.Content)));
                context.BundleCollection.GetBundleFor(context.BundleVirtualPath).CdnPath = string.Format("{0}?v={1}", uri, hash);
            }
        }
开发者ID:tamilselvamr,项目名称:branch,代码行数:31,代码来源:BundleExtentions.cs


示例5: Process

        /// <summary>
        ///     The process.
        /// </summary>
        /// <param name="context">
        ///     The context.
        /// </param>
        /// <param name="bundleResponse">
        ///     The bundle response.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Argument NULL Exception
        /// </exception>
        public void Process(BundleContext context, BundleResponse bundleResponse)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (bundleResponse == null)
            {
                throw new ArgumentNullException("bundleResponse");
            }

            context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();

            IEnumerable<BundleFile> bundleFiles = bundleResponse.Files;
            bundleResponse.Content = Process(ref bundleFiles);

            // set bundle response files back (with imported ones)
            if (context.EnableOptimizations)
            {
                bundleResponse.Files = bundleFiles;
            }

            bundleResponse.ContentType = "text/css";
        }
开发者ID:vardars,项目名称:System.Web.Optimization.Less,代码行数:37,代码来源:LessTransform.cs


示例6: Process

 public void Process(BundleContext context, BundleResponse response)
 {
     var config = new DotlessConfiguration();
     // config.Plugins.Add(new BuildNumberPluginConfigurator());
     response.Content = Less.Parse(response.Content, config);
     response.ContentType = "text/css";
 }
开发者ID:namenotrequired,项目名称:Perpetuality,代码行数:7,代码来源:BundleConfig.cs


示例7: Process

        public override void Process(BundleContext context, BundleResponse response)
        {
            var compressor = new CssCompressor();

            response.Content = compressor.Compress(response.Content);
            response.ContentType = ContentTypes.Css;
        }    
开发者ID:JamieDixon,项目名称:Web.Optimization,代码行数:7,代码来源:YuiCssMinify.cs


示例8: TransformUrls

		private void TransformUrls(BundleContext context, BundleResponse response)
		{
			response.Content = String.Empty;

			var builder = new StringBuilder();

			foreach (var cssFileInfo in response.Files)
			{
				if (cssFileInfo.VirtualFile == null) continue;

				string content;
				using (var streamReader = new StreamReader(cssFileInfo.VirtualFile.Open())) { content = streamReader.ReadToEnd(); }
				if (content.IsNullOrWhiteSpace()) continue;

				var matches = _pattern.Matches(content);
				if (matches.Count > 0)
				{
					foreach (Match match in matches)
					{
						var cssRelativeUrl = match.Groups[2].Value;
						var rootRelativeUrl = TransformUrl(context, cssRelativeUrl, cssFileInfo);

						var quote = match.Groups[1].Value;
						var replace = String.Format("url({0}{1}{0})", quote, rootRelativeUrl);
						content = content.Replace(match.Groups[0].Value, replace);
					}
				}

				builder.AppendLine(content);
			}

			response.ContentType = "text/css";
			response.Content = builder.ToString();
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:34,代码来源:StyleRelativePathTransform.cs


示例9: Process

		public void Process(BundleContext context, BundleResponse response)
		{
			Assert.ArgumentNotNull(response, "response");

			response.Content = new CssCompressor().Compress(response.Content);
			response.ContentType = "text/css";
		}
开发者ID:unger,项目名称:Bundling.Extensions,代码行数:7,代码来源:YuiCssMinify.cs


示例10: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            var builder = new StringBuilder();

            foreach (var file in response.Files)
            {
                var path =
                   context.HttpContext.Server.MapPath(
                       file.IncludedVirtualPath);

                var fileInfo = new FileInfo(path);

                if (!fileInfo.Exists)
                {
                    continue;
                }

                var content = ResolveImports(fileInfo);

                builder.AppendLine(
                    _configuration.Web
                        ? dotless.Core.LessWeb.Parse(content, _configuration)
                        : dotless.Core.Less.Parse(content, _configuration));
            }

            response.ContentType = ContentType.Css;
            response.Content = builder.ToString();
        }
开发者ID:philipproplesch,项目名称:Web.Optimization,代码行数:28,代码来源:LessTransform.cs


示例11: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            var output = new StringBuilder();
            var errors = new StringBuilder();
            var applicationFolder = context.HttpContext.Server.MapPath(@"~/");
            var nodejs = Path.GetFullPath(applicationFolder + @"..\nodejs");
            foreach (var file in response.Files)
            {
                 using (var process = new Process())
                 {
                        process.StartInfo = new ProcessStartInfo
                        {
                            FileName = Path.Combine(nodejs, "node.exe"),
                            Arguments = Path.Combine(nodejs, @"node_modules\less\bin\lessc") + " " + file.FullName,
                            CreateNoWindow = true,
                            RedirectStandardError = true,
                            RedirectStandardOutput = true,
                            UseShellExecute = false,
                            WorkingDirectory = applicationFolder,
                        };
                        process.OutputDataReceived += (sender, e) => output.AppendLine(e.Data);
                        process.ErrorDataReceived += (sender, e) => { if (!String.IsNullOrWhiteSpace(e.Data)) errors.AppendLine(e.Data); };
                        process.Start();
                        process.BeginOutputReadLine();
                        process.BeginErrorReadLine();
                        process.WaitForExit();
                    }
                }

                if (!String.IsNullOrEmpty(errors.ToString())) throw new LessParsingException(errors.ToString());
                response.ContentType = "text/css";
                response.Content = output.ToString();
        }
开发者ID:pawelpabich,项目名称:SampleBundleImplementationsForLess,代码行数:33,代码来源:NodeJsTransform.cs


示例12: Process

 /// <summary>
 /// Transforms the content in the <see cref="T:System.Web.Optimization.BundleResponse" /> object.
 /// </summary>
 /// <param name="context">The bundle context.</param>
 /// <param name="response">The bundle response.</param>
 public void Process(BundleContext context, BundleResponse response)
 {
     if (!context.EnableInstrumentation)
     {
         Manager.Process(response.Files.Select(x => new Asset(x.IncludedVirtualPath)).ToList<IAsset>(), context, response);
     }
 }
开发者ID:modulexcite,项目名称:Batman,代码行数:12,代码来源:Transformer.cs


示例13: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            var sharedLessFile = CreateSharedLessFile(response.Files);

            response.Content = GenerateCss(sharedLessFile, context);
            response.ContentType = "text/css";
        }
开发者ID:helephant,项目名称:dotless,代码行数:7,代码来源:LessTranform.cs


示例14: Process

        public virtual void Process(BundleContext context, BundleResponse response)
        {
            #if DEBUG
            // set BundleContext.UseServerCache to false in order to process all bundle request and generate dynamic response
            context.UseServerCache = false;
            response.Cacheability = HttpCacheability.NoCache;
            #endif

            var contentBuilder = new StringBuilder();
            contentBuilder.AppendLine("// Created on: " + DateTime.Now.ToString(CultureInfo.InvariantCulture));
            contentBuilder.AppendLine("require(['angular'], function(angular) {");
            contentBuilder.AppendLine("    angular.module('bundleTemplateCache', []).run(['$templateCache', function($templateCache) {");
            contentBuilder.AppendLine("        $templateCache.removeAll();");
            foreach (BundleFile file in response.Files)
            {
                string fileId = VirtualPathUtility.ToAbsolute(file.IncludedVirtualPath);
                string filePath = HttpContext.Current.Server.MapPath(file.IncludedVirtualPath);
                string fileContent = File.ReadAllText(filePath);

                contentBuilder.AppendFormat("        $templateCache.put({0},{1});" + Environment.NewLine,
                    JsonConvert.SerializeObject(fileId),
                    JsonConvert.SerializeObject(fileContent));
            }

            contentBuilder.AppendLine("    }]);");
            contentBuilder.AppendLine("});");

            response.Content = contentBuilder.ToString();
            response.ContentType = "text/javascript";
        }
开发者ID:JohannesHoppe,项目名称:Artikel,代码行数:30,代码来源:AngularJsHtmlCombine.cs


示例15: Process

 public void Process(BundleContext context, BundleResponse response)
 {
     string content = response.get_Content();
     StringBuilder stringBuilder = new StringBuilder();
     char[] chrArray = new char[1];
     chrArray[0] = '\n';
     string[] strArrays = content.Split(chrArray);
     for (int i = 0; i < (int)strArrays.Length; i++)
     {
         string str = strArrays[i];
         Match match = Regex.Match(str, "url\\([\\\"\\'](.*)\\?embed[\\\"\\']\\)");
         if (match.Success)
         {
             string str1 = match.Result("$1");
             str1 = ConvertCssUrlsToDataUris.CleanPath(str1);
             try
             {
                 str1 = HttpContext.Current.Server.MapPath(str1);
             }
             catch (ArgumentException argumentException)
             {
                 throw new Exception(string.Concat("Illegal Characters : ", str1));
             }
             stringBuilder.AppendLine(str.Replace(match.Result("$0"), this.GetDataUri(str1)));
             stringBuilder.AppendLine(str.Replace("background", "*background"));
         }
         else
         {
             stringBuilder.Append(str);
         }
     }
     response.set_ContentType("text/css");
     response.set_Content(stringBuilder.ToString());
 }
开发者ID:hurricanepkt,项目名称:BundlingDataURI,代码行数:34,代码来源:ConvertCssUrlsToDataUris.cs


示例16: Process

        /// <summary>
        /// The implementation of the <see cref="IBundleTransform"/> interface
        /// </summary>
        /// <param name="context"></param>
        /// <param name="response"></param>
        public void Process(BundleContext context, BundleResponse response)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }
            if (null == response)
            {
                throw new ArgumentNullException("response");
            }

            var urlMatcher = new Regex(@"url\((['""]?)(.+?)\1\)", RegexOptions.IgnoreCase);

            var content = new StringBuilder();
            foreach (var fileInfo in response.Files)
            {
                if (fileInfo.Directory == null)
                {
                    continue;
                }
                var fileContent = _fileProvider.ReadAllText(fileInfo.FullName);
                var directory = fileInfo.Directory.FullName;
                content.Append(urlMatcher.Replace(fileContent, match => ProcessMatch(match, directory)));
            }
            
            context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();
            response.Content = content.ToString();
            response.ContentType = CssContentType;
        }
开发者ID:jfbourke,项目名称:JB.WebOptimization.Transformers,代码行数:34,代码来源:CssDataUriTransform.cs


示例17: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (response == null)
            {
                throw new ArgumentNullException("response");
            }

            // Grab all of the content.
            var rawContent = new StringBuilder();
            foreach (var fileInfo in response.Files)
            {
                using (var stream = fileInfo.VirtualFile.Open())
                {
                    using (var streamReader = new StreamReader(stream))
                    {
                        rawContent.Append(streamReader.ReadToEnd());
                    }
                }
            }

            // Now lets compress.
            var compressor = DetermineCompressor(_compressorConfig);
            var output = compressor.Compress(rawContent.ToString());
            context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();
            response.Content = output;
            response.ContentType = compressor.ContentType;
        }
开发者ID:jzabroski,项目名称:YUICompressor.NET,代码行数:32,代码来源:YuiCompressorTransform.cs


示例18: Process

        public void Process(BundleContext context, BundleResponse bundle)
        {
            context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();

            var lessParser = new Parser();
            ILessEngine lessEngine = CreateLessEngine(lessParser);

            var content = new StringBuilder();

            var bundleFiles = new List<BundleFile>();

            foreach (var bundleFile in bundle.Files)
            {
                bundleFiles.Add(bundleFile);

                SetCurrentFilePath(lessParser, bundleFile.VirtualFile.VirtualPath);

                using (var reader = new StreamReader(VirtualPathProvider.OpenFile(bundleFile.VirtualFile.VirtualPath)))
                {
                    content.Append(lessEngine.TransformToCss(reader.ReadToEnd(), bundleFile.VirtualFile.VirtualPath));
                    content.AppendLine();

                    bundleFiles.AddRange(GetFileDependencies(lessParser));
                }
            }

            if (BundleTable.EnableOptimizations)
            {
                // include imports in bundle files to register cache dependencies
                bundle.Files = bundleFiles.Distinct().ToList();
            }

            bundle.ContentType = "text/css";
            bundle.Content = content.ToString();
        }
开发者ID:prashantkhandelwal,项目名称:Bloggy,代码行数:35,代码来源:BundleConfig.cs


示例19: Process

        public void Process(BundleContext context, BundleResponse response)
        {
            var strBundleResponse = new StringBuilder();
            // Javascript module for Angular that uses templateCache
            strBundleResponse.AppendFormat(
                @"angular.module('{0}').run(['$templateCache',function(t){{",
                _moduleName);

            foreach (var file in response.Files)
            {
                string content;

                //Get content
                using (var stream = new StreamReader(file.VirtualFile.Open()))
                {
                    content = stream.ReadToEnd();
                }

                //Remove breaks and escape qoutes
                content = Regex.Replace(content, @"\r\n?|\n", "");
                content = content.Replace("'", "\\'");

                // Create insert statement with template
                strBundleResponse.AppendFormat(
                    @"t.put('{0}','{1}');", file.VirtualFile.VirtualPath.Substring(1), content);
            }
            strBundleResponse.Append(@"}]);");

            response.Files = new BundleFile[] {};
            response.Content = strBundleResponse.ToString();
            response.ContentType = "text/javascript";
        }
开发者ID:F2EVarMan,项目名称:Projise,代码行数:32,代码来源:PartialsTransform.cs


示例20: Process

 public void Process(BundleContext context, BundleResponse response)
 {
     if (!response.Files.Any(f => f.VirtualFile.VirtualPath.ToLowerInvariant().Contains("jquery")))
     {
         response.Content = CopyrigthText + response.Content;
     }
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:CopyrigthTransform.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Burden类代码示例发布时间:2022-05-24
下一篇:
C# BundleInstaller类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap