public override IEnumerable <string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap) { return(packageSession.Packages .SelectMany(package => package.Assets) // Select all assets .Where(assetItem => assetItem.Asset.Tags.Any(tag => Tags.Contains(tag))) // Matches tags .Select(x => x.Location.FullPath)); // Convert to string; }
private void CollectBundle(ResolvedBundle resolvedBundle, string assetUrl, IAssetIndexMap assetIndexMap) { // Check if index map contains it already (that also means object id has been stored as well) if (resolvedBundle.DependencyIndexMap.ContainsKey(assetUrl) || resolvedBundle.IndexMap.ContainsKey(assetUrl)) { return; } ObjectId objectId; if (!assetIndexMap.TryGetValue(assetUrl, out objectId)) { throw new InvalidOperationException(string.Format("Could not find asset {0} for bundle {1}", assetUrl, resolvedBundle.Name)); } // Add asset to index map resolvedBundle.IndexMap.Add(assetUrl, objectId); // Check if object id has already been added (either as dependency or inside this actual pack) // As a consequence, no need to check references since they will somehow be part of this package or one of its dependencies. if (resolvedBundle.DependencyObjectIds.Contains(objectId) || !resolvedBundle.ObjectIds.Add(objectId)) { return; } foreach (var reference in GetChunkReferences(ref objectId)) { CollectBundle(resolvedBundle, reference, assetIndexMap); } }
public override IEnumerable<string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap) { return packageSession.Packages .SelectMany(package => package.Assets) // Select all assets .Where(assetItem => assetItem.Asset.Tags.Any(tag => Tags.Contains(tag))) // Matches tags .Select(x => x.Location.FullPath); // Convert to string; }
/// <inheritdoc/> public override IEnumerable <string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap) { // Check if we need to create or regenerate regex. bool needGenerateRegex = false; if (regexes == null || regexes.Length != Paths.Count) { needGenerateRegex = true; } else { // Check used pattern for (int i = 0; i < Paths.Count; ++i) { if (Paths[i] != regexes[i].Key) { needGenerateRegex = true; break; } } } // Transform gitignore patterns to regex. if (needGenerateRegex) { regexes = Paths.Select(x => new KeyValuePair <string, Regex>(x, new Regex(TransformToRegex(x)))).ToArray(); } return(assetIndexMap.GetMergedIdMap() .Select(asset => asset.Key) // Select url .Where(assetUrl => regexes.Any(regex => regex.Value.IsMatch(assetUrl)))); // Check if any Regex matches }
/// <inheritdoc/> public override IEnumerable<string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap) { // Check if we need to create or regenerate regex. bool needGenerateRegex = false; if (regexes == null || regexes.Length != Paths.Count) { needGenerateRegex = true; } else { // Check used pattern for (int i = 0; i < Paths.Count; ++i) { if (Paths[i] != regexes[i].Key) { needGenerateRegex = true; break; } } } // Transform gitignore patterns to regex. if (needGenerateRegex) regexes = Paths.Select(x => new KeyValuePair<string, Regex>(x, new Regex(TransformToRegex(x)))).ToArray(); return assetIndexMap.GetMergedIdMap() .Select(asset => asset.Key) // Select url .Where(assetUrl => regexes.Any(regex => regex.Value.IsMatch(assetUrl))); // Check if any Regex matches }
private static void Collect(HashSet <ObjectId> objectIds, ObjectId objectId, IAssetIndexMap assetIndexMap) { // Already added? if (!objectIds.Add(objectId)) { return; } using (var stream = AssetManager.FileProvider.OpenStream(DatabaseFileProvider.ObjectIdUrl + objectId, VirtualFileMode.Open, VirtualFileAccess.Read)) { // Read chunk header var streamReader = new BinarySerializationReader(stream); var header = ChunkHeader.Read(streamReader); // Only process chunks if (header != null) { if (header.OffsetToReferences != -1) { // Seek to where references are stored and deserialize them streamReader.NativeStream.Seek(header.OffsetToReferences, SeekOrigin.Begin); List <ChunkReference> references = null; streamReader.Serialize(ref references, ArchiveMode.Deserialize); foreach (var reference in references) { ObjectId refObjectId; var databaseFileProvider = DatabaseFileProvider.ResolveObjectId(reference.Location, out refObjectId); if (databaseFileProvider != null) { Collect(objectIds, refObjectId, databaseFileProvider.AssetIndexMap); } } } } } }
private void CollectReferences(Bundle bundle, HashSet <string> assets, string assetUrl, IAssetIndexMap assetIndexMap) { // Already included? if (!assets.Add(assetUrl)) { return; } ObjectId objectId; if (!assetIndexMap.TryGetValue(assetUrl, out objectId)) { throw new InvalidOperationException(string.Format("Could not find asset {0} for bundle {1}", assetUrl, bundle.Name)); } // Include references foreach (var reference in GetChunkReferences(ref objectId)) { CollectReferences(bundle, assets, reference, assetIndexMap); } }
public DatabaseFileProvider(IAssetIndexMap assetIndexMap, ObjectDatabase objectDatabase, string mountPoint = null) : base(mountPoint) { this.assetIndexMap = assetIndexMap; this.objectDatabase = objectDatabase; }
public abstract IEnumerable <string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap);
private static void Collect(HashSet<ObjectId> objectIds, ObjectId objectId, IAssetIndexMap assetIndexMap) { // Already added? if (!objectIds.Add(objectId)) return; using (var stream = AssetManager.FileProvider.OpenStream("obj/" + objectId, VirtualFileMode.Open, VirtualFileAccess.Read)) { // Read chunk header var streamReader = new BinarySerializationReader(stream); var header = ChunkHeader.Read(streamReader); // Only process chunks if (header != null) { if (header.OffsetToReferences != -1) { // Seek to where references are stored and deserialize them streamReader.NativeStream.Seek(header.OffsetToReferences, SeekOrigin.Begin); List<ChunkReference> references = null; streamReader.Serialize(ref references, ArchiveMode.Deserialize); foreach (var reference in references) { ObjectId refObjectId; var databaseFileProvider = DatabaseFileProvider.ResolveObjectId(reference.Location, out refObjectId); if (databaseFileProvider != null) { Collect(objectIds, refObjectId, databaseFileProvider.AssetIndexMap); } } } } } }
public BuildTransaction(IAssetIndexMap assetIndexMap, IEnumerable<IDictionary<ObjectUrl, OutputObject>> outputObjectsGroups) { this.assetIndexMap = assetIndexMap; this.outputObjectsGroups = outputObjectsGroups; }
public BuildTransaction(IAssetIndexMap assetIndexMap, IEnumerable <IDictionary <ObjectUrl, OutputObject> > outputObjectsGroups) { this.assetIndexMap = assetIndexMap; this.outputObjectsGroups = outputObjectsGroups; }
public abstract IEnumerable<string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap);
/// <summary> /// Merges the values from the given asset index map. /// </summary> /// <param name="assetIndexMap">The asset index map to merge.</param> public void Merge(IAssetIndexMap assetIndexMap) { Merge(assetIndexMap.GetMergedIdMap()); }