public IEnumerable<IResource> FindResources(ResourceType resourceType) { var combined = new List<IResource>(); foreach (IResourceFinder finder in _finders) { var found = finder.FindResources(resourceType).Where(IsNotExcluded); combined.AddRange(found); } return combined; }
/// <summary> /// Recursively finds resources in the given directory with the given extension. /// </summary> /// <param name="resourceType">The resource type to be found.</param> /// <returns></returns> public IEnumerable<IResource> FindResources(ResourceType resourceType) { foreach (var extension in resourceType.FileExtensions) { string[] files = Directory.GetFiles(_directory, "*" + extension, SearchOption.AllDirectories); foreach (string filePath in files) { yield return new FileResource(filePath, _directory); } } }
public IEnumerable<IResource> FindResources(ResourceType resourceType) { var resources = _inner.FindResources(resourceType).ToArray(); var externallyCompiledPairs = resources.ExternallyCompiled(); foreach (var resource in resources) { var externallyCompiledPair = externallyCompiledPairs.SingleOrDefault(resource.VirtualPath); if(externallyCompiledPair == null) { yield return resource; } else { var resourceWithProperMode = externallyCompiledPair.WithMode(_resourceMode); if(resourceWithProperMode.VirtualPath.EqualsVirtualPath(resource.VirtualPath)) yield return new ExternallyCompiledResource(externallyCompiledPair, resourceWithProperMode); } } }
public void StoreResources(ResourceType resourceType, IEnumerable<IResource> resources) { _resources.Set(resourceType, resources); }
public IEnumerable<IResource> FindResources(ResourceType resourceType) { return from resourceName in _assembly.GetManifestResourceNames() where resourceType.FileExtensions.Any(resourceName.EndsWith) select CreateEmbeddedResource(resourceName); }
public ResourceGroup(string consolidatedUrl, IEnumerable<IResource> resources) { ConsolidatedUrl = consolidatedUrl; _resources = resources.ToList(); _resourceType = ResourceType.FromPath(ConsolidatedUrl); }
public static IEnumerable<IResource> GetOrAddResources(this IResourceCache resourceCache, ResourceType resourceType, Func<IEnumerable<IResource>> findResources) { IEnumerable<IResource> resources; if (resourceCache.TryGetResources(resourceType, out resources)) return resources; resources = findResources(); if(resources != null) { resourceCache.StoreResources(resourceType, resources); } return resources; }
public bool TryGetResources(ResourceType resourceType, out IEnumerable<IResource> cachedResources) { cachedResources = null; return false; }
public void StoreResources(ResourceType resourceType, IEnumerable<IResource> resources) { }
private IResourceGroupManager GroupManagerFor(ResourceType resourceType) { if (resourceType == ResourceType.Stylesheet) return _styleGroups; else return _scriptGroups; }
private IEnumerable<PreCompiledResourceGroup> ConsolidateGroupsInternal(ResourceType resourceType, IResourceGroupManager groupTemplates, Action<ICompiledResource> onCompiled) { if (!groupTemplates.Any()) return Enumerable.Empty<PreCompiledResourceGroup>(); var allResources = _finder.FindResources(resourceType).ToArray(); var preConsolidatedGroups = new List<PreCompiledResourceGroup>(); groupTemplates.EachGroup(allResources, group => { var consolidatedResource = CompileGroup(group); onCompiled(consolidatedResource); var preConsolidatedGroup = new PreCompiledResourceGroup { ConsolidatedUrl = group.ConsolidatedUrl, Resources = consolidatedResource.Resources.Select(resource => resource.VirtualPath).ToList() }; preConsolidatedGroups.Add(preConsolidatedGroup); }); return preConsolidatedGroups; }
private PreCompiledResourceReport CompileAllResourcesOfType(ResourceType resourceType, Action<ICompiledResource> onCompiled) { var groupManager = GroupManagerFor(resourceType); return new PreCompiledResourceReport { Groups = ConsolidateGroupsInternal(resourceType, groupManager, onCompiled).ToList(), SingleResources = CompileUnconsolidatedResources(resourceType, onCompiled) .Select(r => new PreCompiledSingleResource { OriginalPath = r.Resources.Single().VirtualPath, CompiledPath = r.CompiledPath }).ToList() }; }
public IEnumerable<IResource> FindResources(ResourceType resourceType) { yield break; }
public bool TryGetResources(ResourceType resourceType, out IEnumerable<IResource> cachedResources) { return GetInnerCache().TryGetResources(resourceType, out cachedResources); }
public void StoreResources(ResourceType resourceType, IEnumerable<IResource> resources) { GetInnerCache().StoreResources(resourceType, resources); }
public bool TryGetResources(ResourceType resourceType, out IEnumerable<IResource> cachedResources) { return _resources.TryGetValue(resourceType, out cachedResources); }
public IEnumerable<IResource> FindResources(ResourceType resourceType) { return _cache.GetOrAddResources(resourceType, () => _inner.FindResources(resourceType)); }
public IEnumerable<ICompiledResource> CompileUnconsolidatedResources(ResourceType resourceType, Action<ICompiledResource> handleCompiledResource) { var resources = _finder.FindResources(resourceType).ToArray(); var groupManager = GroupManagerFor(resourceType); var unconsolidatedResources = (from resource in resources where !resource.IsExternallyCompiled() && !groupManager.IsPartOfGroup(resource.VirtualPath) && CanCompileIndividually(resource) select resource).ToList(); var compiledResources = new List<ICompiledResource>(); foreach (var unconsolidatedResource in unconsolidatedResources) { var compiledResource = CompileResource(unconsolidatedResource); handleCompiledResource(compiledResource); compiledResources.Add(compiledResource); } return compiledResources; }