Beispiel #1
0
        public AssmanContext BuildContext(ResourceMode resourceMode, IResourceFinder fileFinder, IPreCompiledReportPersister preCompiledPersister)
        {
            var context = AssmanContext.Create(resourceMode);

            context.ConfigurationLastModified = LastModified(PathResolver);
            context.ConsolidateScripts        = Consolidate.IsTrue(resourceMode) && Scripts.Consolidate.IsTrue(resourceMode);
            context.ConsolidateStylesheets    = Consolidate.IsTrue(resourceMode) && Stylesheets.Consolidate.IsTrue(resourceMode);
            context.GZip = GZip.IsTrue(resourceMode);
            context.ManageDependencies = ManageDependencies;
            context.AddFinder(fileFinder);
            context.AddAssemblies(Assemblies.GetAssemblies());
            context.ScriptGroups.AddGlobalDependencies(Scripts.GlobalDependencies.Cast <GlobalDependenciesElement>().Select(e => e.Path));
            context.ScriptGroups.AddRange(Scripts.Groups.Cast <IResourceGroupTemplate>());
            context.StyleGroups.AddGlobalDependencies(Stylesheets.GlobalDependencies.Cast <GlobalDependenciesElement>().Select(e => e.Path));
            context.StyleGroups.AddRange(Stylesheets.Groups.Cast <IResourceGroupTemplate>());
            context.MapExtensionToContentPipeline(".js", DefaultPipelines.Javascript());
            context.MapExtensionToContentPipeline(".css", DefaultPipelines.Css());
            context.MapExtensionToDependencyProvider(".js", VisualStudioScriptDependencyProvider.GetInstance());
            context.MapExtensionToDependencyProvider(".css", CssDependencyProvider.GetInstance());

            PreCompilationReport preCompilationReport;

            if (preCompiledPersister.TryGetPreConsolidationInfo(out preCompilationReport))
            {
                context.LoadPreCompilationReport(preCompilationReport);
            }

            foreach (var plugin in Plugins.GetPlugins())
            {
                plugin.Initialize(context);
            }

            return(context);
        }
        public void SetupContext()
        {
            _finder = new StubResourceFinder();

            _context = AssmanContext.Create(ResourceMode.Release);
            _context.ManageDependencies = true;
            _context.AddFinder(_finder);
            _accessor = new ConsolidatingResourceRegistryAccessor(_context);
        }
        public void SetupContext()
        {
            _dependencyProvider = new Mock<IDependencyProvider>();
            _finder = new Mock<IResourceFinder>();

            _context = AssmanContext.Create(ResourceMode.Release);
            _context.MapExtensionToDependencyProvider(".js", _dependencyProvider.Object);
            _context.AddFinder(_finder.Object);
        }
Beispiel #4
0
 public void Initialize(AssmanContext context)
 {
     ResourceType.Stylesheet.AddFileExtension(LessFileExtension);
     var lessPipeline = new ContentFilterPipeline();
     lessPipeline.Add(new LessContentFilter());
     lessPipeline.Add(CssRelativePathFilter.GetInstance());
     context.MapExtensionToContentPipeline(LessFileExtension, lessPipeline);
     context.MapExtensionToDependencyProvider(LessFileExtension, CssDependencyProvider.GetInstance());
 }
        public void SetupContext()
        {
            _context = AssmanContext.Create(ResourceMode.Debug);
            _groupElement = new ScriptGroupElement();
            _groupElement.ConsolidatedUrl = "~" + ConsolidatedPath;
            _context.ScriptGroups.Add(_groupElement);

            _configLoader = new Mock<IConfigLoader>();
            _configLoader.Setup(l => l.GetSection<CompilationSection>(It.IsAny<string>())).Returns(new CompilationSection());

            _handlerFactory = new ResourceHttpHandlerFactory(_context, _configLoader.Object);
        }
        public ConsolidatingResourceRegistryAccessor(AssmanContext context)
        {
            var versioningStrategy = new ConfiguredVersioningStrategy(() => context.Version);

            //TODO: Consider lessening dependency from AssmanContext to just the path resolvers
            _scriptRequirements = new ResourceRequirementCollection();
            _scriptRegistries =
                new ResourceRegistryMap(registryName =>
                    new ConsolidatingResourceRegistry(_scriptRequirements, registryName, context.ScriptPathResolver,
                                                      versioningStrategy));
            _styleRequirements = new ResourceRequirementCollection();
            _styleRegistries = new ResourceRegistryMap(registryName =>
                    new ConsolidatingResourceRegistry(_styleRequirements, registryName, context.StylePathResolver,
                                                      versioningStrategy));
        }
        public void Init()
        {
            _now = DateTime.Now;
            _lastModified = _now.AddYears(-1);
            var resources = new ResourceCollection
            {
                CreateResource("Content1", _lastModified.AddDays(-3)),
                CreateResource("Content2", _lastModified),
                CreateResource("Content3", _lastModified.AddDays(-10))
            };
            _finder = new Mock<IResourceFinder>();
            _finder.Setup(f => f.FindResources(_resourceType)).Returns(resources);

            var groupTemplate = new StubResourceGroupTemplate(new ResourceGroup(VirtualPath, resources));
            groupTemplate.ResourceType = _resourceType;

            var configContext = new AssmanContext(ResourceMode.Debug);
            configContext.AddFinder(_finder.Object);

            _instance = new DynamicallyConsolidatedResourceHandler(VirtualPath, configContext.GetCompiler(), groupTemplate.WithEmptyContext())
            {
                Now = () => _now
            };
        }
 public void Initialize(AssmanContext context)
 {
     var cssPipeline = context.GetContentPipelineForExtension(".css");
     cssPipeline.Add(new YuiCompressorCssContentFilter());
 }
 public void Initialize(AssmanContext context)
 {
     var jsPipeline = context.GetContentPipelineForExtension(".js");
     jsPipeline.Remove<JSMinFilter>();
     jsPipeline.Add(new YuiCompressorJavaScriptContentFilter());
 }
Beispiel #10
0
 public void Initialize(AssmanContext context)
 {
 }
        public void Init()
        {
            _finder = new StubResourceFinder();
            _finder.CreateResource(myScript);
            _finder.CreateResource(mySecondScript);
            _finder.CreateResource(excludedScript);

            _dependencyProvider = new StubDependencyProvider();
            DependencyManagerFactory.ClearDependencyCache();

            _context = AssmanContext.Create(ResourceMode.Debug);
            _context.ConsolidateScripts = true;
            _context.ConfigurationLastModified = DateTime.MinValue;
            _context.AddFinder(_finder);
            _context.MapExtensionToDependencyProvider(".js", _dependencyProvider);
            _groupElement = new ScriptGroupElement();
            _groupElement.ConsolidatedUrl = consolidatedScript;
            _groupElement.Exclude.AddPattern(excludedScript);
            _context.ScriptGroups.Add(_groupElement);

            _registry = new ConsolidatingResourceRegistry(new ResourceRequirementCollection(), "Default", _context.ScriptPathResolver, new ConfiguredVersioningStrategy(() => _context.Version));
        }
Beispiel #12
0
 public void SetupContext()
 {
     DependencyManagerFactory.ClearDependencyCache();
     _finder = new StubResourceFinder();
     _context = new AssmanContext(ResourceMode.Release);
     _context.AddFinder(_finder);
 }
        public void Initialize(AssmanContext context)
        {
            var finder = CreateFinder();

            context.AddFinder(finder);
        }
 internal ResourceHttpHandlerFactory(AssmanContext assmanContext, IConfigLoader configLoader)
 {
     _assmanContext = assmanContext;
     _configLoader = configLoader;
 }