public FileAsset(IFile sourceFile, Bundle parentBundle) { this.parentBundle = parentBundle; this.sourceFile = sourceFile; hash = new Lazy<byte[]>(HashFileContents); // Avoid file IO until the hash is actually needed. }
void IBundleVisitor.Visit(Bundle bundle) { if (IsMatch(bundle.Path)) { isFound = true; } }
Bundle CreateExternalBundle(string url, Bundle referencer) { var bundleFactory = GetBundleFactory(referencer.GetType()); var externalBundle = bundleFactory.CreateExternalBundle(url); externalBundle.Process(settings); return externalBundle; }
public ResourceAsset(string resourceName, Assembly assembly, Bundle parentBundle) { this.resourceName = ResolveResourceName(resourceName, assembly); resourceFile = new ResourceFile("~/" + this.resourceName); this.assembly = assembly; this.parentBundle = parentBundle; this.hash = new Lazy<byte[]>(ComputeHash); }
public string CreateBundleUrl(Bundle bundle) { var url = bundle.Url; if (url.IsUrl()) return url; url = routePrefix + "/" + url; return urlModifier.Modify(url); }
void IBundleVisitor.Visit(Bundle bundle) { normalizedPath = originalPath.IsUrl() ? originalPath : NormalizePath(originalPath, bundle); if (IsMatch(bundle.Path)) { isFound = true; } }
public string CreateBundleUrl(Bundle bundle) { var theme = string.Empty; if (bundle.HtmlAttributes.ContainsAttribute("data-theme")) { theme = bundle.HtmlAttributes["data-theme"]; } return new Url( _inner.CreateBundleUrl(bundle)).AppendQuery("theme", theme); }
void IBundleVisitor.Visit(Bundle bundle) { currentBundle = bundle; var urlReferencesNotYetSeen = bundle.References.Where(IsUrlReferenceNotYetSeen); foreach (var reference in urlReferencesNotYetSeen) { RecordUrlAsSeen(reference); AddNewExternalBundle(reference); } }
string NormalizePath(string path, Bundle bundle) { path = path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); if (path.StartsWith("~")) { return path; } else { return PathUtilities.CombineWithForwardSlashes(bundle.Path, path); } }
void AddBundlesReferencedBy(Bundle bundle, ISet<Bundle> all) { if (all.Contains(bundle)) return; all.Add(bundle); HashSet<Bundle> referencedBundles; if (!bundleImmediateReferences.TryGetValue(bundle, out referencedBundles)) return; foreach (var referencedBundle in referencedBundles) { AddBundlesReferencedBy(referencedBundle, all); } }
public string CreateBundleUrl(Bundle bundle) { return urlModifier.Modify( String.Format( "{0}/{1}/{2}_{3}", routePrefix, ConventionalBundlePathName(bundle.GetType()), bundle.PathWithoutPrefix, bundle.Hash.ToHexString() ) ); }
public Asset_Tests() { root = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); root.CreateSubdirectory("bundle"); bundle = new TestableBundle("~/bundle"); sourceFile = StubFile("asset content"); asset = new FileAsset(sourceFile, bundle); bundle.Assets.Add(asset); var another = new FileAsset(StubFile(fullPath: "~/bundle/another.js"), bundle); bundle.Assets.Add(another); }
public static bool TryGetAssetByPath(this IBundleContainer bundleContainer, string path, out IAsset asset, out Bundle bundle) { var results = from b in bundleContainer.FindBundlesContainingPath(path) let a = b.FindAssetByPath(path) where a != null select new { Bundle = b, Asset = a }; var result = results.FirstOrDefault(); if (result != null) { asset = result.Asset; bundle = result.Bundle; return true; } else { asset = null; bundle = null; return false; } }
public void Visit(Bundle bundle) { if (FoundAsset != null) return; }
public void WhenInterdependenciesBetweenBundlesOfDifferentType_DoesNotDuplicateBundles() { var bundleA = new ScriptBundle("~/a"); var bundleB = new StylesheetBundle("~/b"); var bundleC = new TestableBundle("~/c"); bundleC.AddReference("~/a"); var bundles = new Bundle[] { bundleA, bundleB, bundleC }; var collection = CreateBundleCollection(bundles); collection.BuildReferences(); var sorted = collection.SortBundles(bundles).ToArray(); sorted.ShouldEqual(new Bundle[] { bundleB, bundleA, bundleC }); }
public void Visit(Bundle bundle) { }
static bool AllAssetsEqual(Bundle x, Bundle y) { var collectorX = new CollectLeafAssets(); x.Accept(collectorX); var collectorY = new CollectLeafAssets(); y.Accept(collectorY); var assetsX = collectorX.Assets.OrderBy(a => a.Path); var assetsY = collectorY.Assets.OrderBy(a => a.Path); return assetsX.SequenceEqual(assetsY, new AssetPathComparer()); }
IEnumerable<AssetReference> GetNonSameBundleAssetReferences(Bundle bundle) { var collector = new BundleReferenceCollector(AssetReferenceType.DifferentBundle, AssetReferenceType.Url); bundle.Accept(collector); return collector.CollectedReferences.Select(r => r.AssetReference); }
static bool PathsEqual(Bundle x, Bundle y) { return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase); }
void IBundleVisitor.Visit(Bundle bundle) { }
public void WhenSortDifferentTypesOfBundle_ThenSortsArePartitioned() { var bundleA = new ScriptBundle("~/a"); var bundleB = new StylesheetBundle("~/b"); var bundleC = new ScriptBundle("~/c"); var bundles = new Bundle[] { bundleA, bundleB, bundleC }; var collection = CreateBundleCollection(bundles); collection.BuildReferences(); var sorted = collection.SortBundles(bundles); sorted.ShouldEqual(new Bundle[] { bundleA, bundleC, bundleB }); }
public string CreateBundleUrl(Bundle bundle) { var path = urlModifier.GetPath(bundle.Url, bundle.CacheFilename); var url = cassetteHandlerPrefix + path; return urlModifier.Modify(url); }
public bool BundleContainsPath(string path, Bundle bundle) { pathToFind = path.IsUrl() ? path : NormalizePath(path, bundle); bundle.Accept(this); return isFound; }
public void Visit(Bundle bundle) { currentBundle = bundle; }
static bool TypesEqual(Bundle x, Bundle y) { return x.GetType() == y.GetType(); }
public string CreateBundleUrl(Bundle bundle) { var url = cassetteHandlerPrefix + bundle.Url; return urlModifier.Modify(url); }
public void Visit(Bundle bundle) { VisitBundle(bundle); }