public IHttpHandler GetHandlerUncached(string physicalPathToResource, string appRelativePathToResource)
        {
            var resourceType = ResourceType.FromPath(physicalPathToResource);

            if (resourceType == null)
            {
                return(null);
            }
            var resourceMode = GetResourceMode();

            if (_assmanContext.PreCompiled)
            {
                return(new PreCompiledResourceHandler(physicalPathToResource, resourceType, resourceMode)
                {
                    EnableGZip = _assmanContext.GZip,
                    Mode = resourceMode
                });
            }

            var groupTemplate = _assmanContext.FindGroupTemplate(appRelativePathToResource);

            if (groupTemplate != null)
            {
                return(new DynamicallyConsolidatedResourceHandler(appRelativePathToResource, _assmanContext.GetCompiler(),
                                                                  groupTemplate)
                {
                    MinLastModified = _assmanContext.ConfigurationLastModified,
                    Mode = resourceMode,
                    EnableGZip = _assmanContext.GZip
                });
            }
            else
            {
                var fileExtension = Path.GetExtension(physicalPathToResource);

                var contentFilterPipeline = _assmanContext.GetContentPipelineForExtension(fileExtension);
                var contentFilterContext  = new ContentFilterContext
                {
                    Minify = resourceMode == ResourceMode.Release, //TODO: base this off of global minification setting
                    ResourceVirtualPath = appRelativePathToResource
                };

                return(new DynamicallyCompiledIndividualResourceHandler(physicalPathToResource, resourceType, contentFilterPipeline, contentFilterContext)
                {
                    Mode = resourceMode,
                    EnableGZip = _assmanContext.GZip
                });
            }
        }
Beispiel #2
0
        private IEnumerable <string> GlobalDependenciesFor(string path)
        {
            var resourceType = ResourceType.FromPath(path);
            IResourceGroupManager groupManager = null;

            if (resourceType == ResourceType.Script)
            {
                groupManager = _scriptGroups;
            }
            else if (resourceType == ResourceType.Stylesheet)
            {
                groupManager = _styleGroups;
            }

            if (groupManager != null)
            {
                var allGlobalDependencies = groupManager.GetGlobalDependencies();
                return(allGlobalDependencies.TakeWhile(p => !p.Equals(path, Comparisons.VirtualPath)));
            }

            return(Enumerable.Empty <string>());
        }
Beispiel #3
0
        public GroupTemplateContext FindGroupTemplate(string consolidatedUrl)
        {
            var resourceType = ResourceType.FromPath(consolidatedUrl);

            return(GroupManagerOfType(resourceType).GetGroupTemplateOrDefault(consolidatedUrl));
        }
Beispiel #4
0
 public StubResourceGroup(string consolidatedUrl)
 {
     ConsolidatedUrl = consolidatedUrl;
     ResourceType    = ResourceType.FromPath(consolidatedUrl);
 }