Exemple #1
0
        protected string RenderDebug(string name = null)
        {
            string content = null;

            if (!bundleCache.TryGetValue(name, out content))
            {
                DependentFiles.Clear();

                var modifiedGroupBundles = BeforeRenderDebug();
                var sb = new StringBuilder();
                foreach (var groupBundleKVP in modifiedGroupBundles)
                {
                    var groupBundle = groupBundleKVP.Value;
                    var attributes  = GetAdditionalAttributes(groupBundle);
                    var assets      = groupBundle.Assets;

                    DependentFiles.AddRange(GetFiles(assets));
                    foreach (var asset in assets)
                    {
                        string processedFile = ExpandAppRelativePath(asset.LocalPath);
                        sb.Append(FillTemplate(groupBundle, processedFile));
                    }
                }

                content = sb.ToString();
                bundleCache.Add(name, content, DependentFiles);
            }

            return(content);
        }
Exemple #2
0
        protected string RenderDebug(string name = null)
        {
            string content = null;

            DependentFiles.Clear();

            var modifiedGroupBundles = BeforeRenderDebug();
            var sb = new StringBuilder();

            foreach (var groupBundleKVP in modifiedGroupBundles)
            {
                var groupBundle = groupBundleKVP.Value;
                var attributes  = GetAdditionalAttributes(groupBundle);
                var assets      = groupBundle.Assets;

                DependentFiles.AddRange(GetFiles(assets));
                foreach (var asset in assets)
                {
                    var inputFile = GetInputFile(asset);
                    var files     = inputFile.TryResolve(allowedExtensions);

                    if (asset.IsEmbeddedResource)
                    {
                        var tsb = new StringBuilder();

                        foreach (var fn in files)
                        {
                            tsb.Append(ReadFile(fn) + "\n\n\n");
                        }

                        var renderer      = new FileRenderer(fileWriterFactory);
                        var processedFile = ExpandAppRelativePath(asset.LocalPath);
                        renderer.Render(tsb.ToString(), FileSystem.ResolveAppRelativePathToFileSystem(processedFile));
                        sb.AppendLine(FillTemplate(groupBundle, processedFile));
                    }
                    else if (asset.RemotePath != null)
                    {
                        sb.AppendLine(FillTemplate(groupBundle, ExpandAppRelativePath(asset.LocalPath)));
                    }
                    else
                    {
                        foreach (var file in files)
                        {
                            var    relativePath = FileSystem.ResolveFileSystemPathToAppRelative(file);
                            string path;
                            if (HttpContext.Current == null)
                            {
                                path = (asset.LocalPath.StartsWith("~") ? "" : "/") + relativePath;
                            }
                            else
                            {
                                if (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/"))
                                {
                                    path = HttpRuntime.AppDomainAppVirtualPath + relativePath;
                                }
                                else
                                {
                                    path = HttpRuntime.AppDomainAppVirtualPath + "/" + relativePath;
                                }
                            }
                            sb.AppendLine(FillTemplate(groupBundle, path));
                        }
                    }
                }
            }

            foreach (var cntnt in arbitrary)
            {
                sb.AppendLine(string.Format(tagFormat, cntnt));
            }

            content = sb.ToString();

            if (bundleCache.ContainsKey(name))
            {
                bundleCache.Remove(name);
            }
            bundleCache.Add(name, content, DependentFiles);

            return(content);
        }