Exemplo n.º 1
0
 internal DependencyManager(IResourceFinder resourceFinder, IDependencyCache dependencyCache, IResourceGroupManager scriptGroups, IResourceGroupManager styleGroups, ResourceMode resourceMode)
 {
     _resourceFinder = resourceFinder;
     _dependencyCache = dependencyCache;
     _scriptGroups = scriptGroups;
     _styleGroups = styleGroups;
     _resourceMode = resourceMode;
 }
Exemplo n.º 2
0
 public ResourceCompiler(ContentFilterPipelineMap contentFilterPipelineMap, DependencyManager dependencyManager, IResourceGroupManager scriptGroups, IResourceGroupManager styleGroups, IResourceFinder finder, ResourceMode resourceMode)
 {
     _contentFilterPipelineMap = contentFilterPipelineMap;
     _dependencyManager = dependencyManager;
     _scriptGroups = scriptGroups;
     _styleGroups = styleGroups;
     _finder = finder;
     _resourceMode = resourceMode;
 }
Exemplo n.º 3
0
 public ResourceTestContext(ResourceMode resourceMode = ResourceMode.Debug)
 {
     Mode = resourceMode;
     _innerFinder = new StubResourceFinder();
     _outerFinder = new ResourceModeFilteringFinder(resourceMode, _innerFinder);
     _contentFilterPipelineMap = new ContentFilterPipelineMap();
     _scriptGroups = new ResourceGroupManager(Mode);
     _styleGroups = new ResourceGroupManager(Mode);
     _dependencyCache = new InMemoryDependencyCache();
     _dependencyProvider = new StubDependencyProvider();
     _dependencyManager = new DependencyManager(_outerFinder, _dependencyCache, _scriptGroups, _styleGroups, resourceMode);
     _dependencyManager.MapProvider(".js", _dependencyProvider);
     _dependencyManager.MapProvider(".css", _dependencyProvider);
 }
Exemplo n.º 4
0
        public void FindAppliesFilter()
        {
            string resourceName = "myscriptfile.js";
            _dirMgr.CreateFile(resourceName, "");
            string filteredResourceName = "filtered.js";
            _dirMgr.CreateFile(filteredResourceName, "");

            _finder = ResourceFinderFactory.GetInstance(_dirMgr.DirectoryName);
            var resources = _finder.FindResources(ResourceType.Script)
                .Where(r => r.Name != filteredResourceName).ToList();

            Assert.That(resources, Is.Not.Null);
            Assert.That(resources.Count, Is.EqualTo(1));
            Assert.That(resources[0].Name, Is.EqualTo(resourceName));
        }
Exemplo n.º 5
0
        internal AssmanContext(ResourceMode resourceMode)
        {
            var resourceCache = ResourceCacheFactory.GetCache(resourceMode);

            _scriptGroups = ResourceGroupManager.GetInstance(resourceMode, resourceCache);
            _styleGroups = ResourceGroupManager.GetInstance(resourceMode, resourceCache);
            _compositeFinder = new CompositeResourceFinder();
            _compositeFinder.Exclude(new ConsolidatedResourceExcluder(_scriptGroups));
            _compositeFinder.Exclude(new ConsolidatedResourceExcluder(_styleGroups));
            _compositeFinder.Exclude(new PreCompiledResourceExcluder());
            _compositeFinder.Exclude(new VsDocResourceExcluder());
            _finder = new ResourceModeFilteringFinder(resourceMode, new CachingResourceFinder(resourceCache, _compositeFinder));
            _filterPipelineMap = new ContentFilterPipelineMap();
            _assemblies = new List<Assembly>();
            _dependencyManager = DependencyManagerFactory.GetDependencyManager(_finder, _scriptGroups, _styleGroups, resourceMode);
            _resourceMode = resourceMode;
            _scriptPathResolver = new ResourcePathResolver(_scriptGroups, _dependencyManager, _finder);
            _stylePathResolver = new ResourcePathResolver(_styleGroups, _dependencyManager, _finder);
        }
Exemplo n.º 6
0
 public IResourceGroup GetGroupOrDefault(string consolidatedUrl, IResourceFinder finder)
 {
     throw NotSupported();
 }
Exemplo n.º 7
0
 public IResourceGroup GetGroupOrDefault(string consolidatedUrl, IResourceFinder finder)
 {
     return _resourceCache.GetOrAddGroup(consolidatedUrl, () =>
     {
         return _inner.GetGroupOrDefault(consolidatedUrl, finder);
     });
 }
Exemplo n.º 8
0
 public ResourcePathResolver(IResourceGroupManager groupManager, DependencyManager dependencyManager, IResourceFinder finder)
 {
     _groupManager = groupManager;
     _dependencyManager = dependencyManager;
     _finder = finder;
 }
Exemplo n.º 9
0
 public IResourceGroup GetGroupOrDefault(string consolidatedUrl, IResourceFinder finder)
 {
     throw NotSupported();
 }
Exemplo n.º 10
0
 public static DependencyManager GetDependencyManager(IResourceFinder finder, IResourceGroupManager scriptGroups, IResourceGroupManager styleGroups)
 {
     return(new DependencyManager(finder, _dependencyCache, scriptGroups, styleGroups));
 }
Exemplo n.º 11
0
            public IEnumerable <string> GetResourceUrlsInGroup(string consolidatedUrl, IResourceFinder finder)
            {
                //NOTE: This is basically a duplication of the implementation in _inner.GetResourceUrlsInGroup, but we don't delegate
                //to it because then it would bypass the _resourceCache
                var group = GetGroupOrDefault(consolidatedUrl, finder);

                if (group == null)
                {
                    return(Enumerable.Empty <string>());
                }
                else
                {
                    return(group.GetResources().Select(r => r.VirtualPath));
                }
            }
Exemplo n.º 12
0
 public void Init()
 {
     _instance = ResourceFinderFactory.GetInstance(this.GetType().Assembly);
 }
Exemplo n.º 13
0
        public IResourceGroup GetGroupOrDefault(string consolidatedUrl, IResourceFinder finder)
        {
            var groupTemplateContext = GetGroupTemplateOrDefault(consolidatedUrl);
            if (groupTemplateContext == null)
                return null;

            var group = groupTemplateContext.FindGroupOrDefault(finder, consolidatedUrl, _resourceMode);
            if (group == null)
                return null;

            return group;
        }
Exemplo n.º 14
0
 public IEnumerable<string> GetResourceUrlsInGroup(string consolidatedUrl, IResourceFinder finder)
 {
     //NOTE: This is basically a duplication of the implementation in _inner.GetResourceUrlsInGroup, but we don't delegate
     //to it because then it would bypass the _resourceCache
     var group = GetGroupOrDefault(consolidatedUrl, finder);
     if (group == null)
         return Enumerable.Empty<string>();
     else
         return group.GetResources().Select(r => r.VirtualPath);
 }
Exemplo n.º 15
0
 public ResourceModeFilteringFinder(ResourceMode resourceMode, IResourceFinder inner)
 {
     _resourceMode = resourceMode;
     _inner = inner;
 }
Exemplo n.º 16
0
 public IEnumerable<string> GetResourceUrlsInGroup(string consolidatedUrl, IResourceFinder finder)
 {
     IEnumerable<string> resourceUrls;
     if (_consolidatedUrlMap.TryGetValue(consolidatedUrl, out resourceUrls))
         return resourceUrls;
     else
         return Enumerable.Empty<string>();
 }
Exemplo n.º 17
0
 public void AddFinder(IResourceFinder finder)
 {
     _finders.Add(finder);
 }
Exemplo n.º 18
0
 public static DependencyManager GetDependencyManager(IResourceFinder finder, IResourceGroupManager scriptGroups, IResourceGroupManager styleGroups, ResourceMode resourceMode)
 {
     return new DependencyManager(finder, _dependencyCache, scriptGroups, styleGroups, resourceMode);
 }
Exemplo n.º 19
0
 public ResourceCompiler(ContentFilterPipelineMap contentFilterPipelineMap, DependencyManager dependencyManager, IResourceGroupManager scriptGroups, IResourceGroupManager styleGroups, IResourceFinder finder, ResourceMode resourceMode)
 {
     _contentFilterPipelineMap = contentFilterPipelineMap;
     _dependencyManager        = dependencyManager;
     _scriptGroups             = scriptGroups;
     _styleGroups  = styleGroups;
     _finder       = finder;
     _resourceMode = resourceMode;
 }
Exemplo n.º 20
0
 public void Setup()
 {
     _dirMgr = new TempDirectoryManager();
     _finder = ResourceFinderFactory.GetInstance(_dirMgr.DirectoryName);
 }
Exemplo n.º 21
0
        public IResourceGroup FindGroupOrDefault(IResourceFinder finder, string consolidatedUrl, ResourceMode mode)
        {
            var resources = finder.FindResources(GroupTemplate.ResourceType).ToArray();

            return FindGroupOrDefault(resources, consolidatedUrl, mode);
        }
Exemplo n.º 22
0
 public void AddFinder(IResourceFinder finder)
 {
     _compositeFinder.AddFinder(finder);
 }
Exemplo n.º 23
0
 public IEnumerable<IResourceGroup> GetGroups(IResourceFinder finder, ResourceMode mode)
 {
     var resources = finder.FindResources(GroupTemplate.ResourceType);
     return GetGroups(resources, mode);
 }
Exemplo n.º 24
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.MutuallyExclusiveGroups = MutuallyExclusiveGroups;
            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;
        }
Exemplo n.º 25
0
 public void Init()
 {
     _instance = ResourceFinderFactory.GetInstance(this.GetType().Assembly);
 }
Exemplo n.º 26
0
 public CachingResourceFinder(IResourceCache cache, IResourceFinder inner)
 {
     _cache = cache;
     _inner = inner;
 }
Exemplo n.º 27
0
 public IEnumerable<string> GetResourceUrlsInGroup(string consolidatedUrl, IResourceFinder finder)
 {
     var group = GetGroupOrDefault(consolidatedUrl, finder);
     if (group == null)
         return Enumerable.Empty<string>();
     else
         return group.GetResources().Select(r => r.VirtualPath);
 }