예제 #1
0
 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;
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
 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;
 }
예제 #4
0
        /// <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
        }
예제 #5
0
파일: PathSelector.cs 프로젝트: cg123/xenko
        /// <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
        }
예제 #6
0
        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);
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
 public DatabaseFileProvider(IAssetIndexMap assetIndexMap, ObjectDatabase objectDatabase, string mountPoint = null) : base(mountPoint)
 {
     this.assetIndexMap  = assetIndexMap;
     this.objectDatabase = objectDatabase;
 }
예제 #9
0
 public abstract IEnumerable <string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap);
예제 #10
0
        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);
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
 public BuildTransaction(IAssetIndexMap assetIndexMap, IEnumerable<IDictionary<ObjectUrl, OutputObject>> outputObjectsGroups)
 {
     this.assetIndexMap = assetIndexMap;
     this.outputObjectsGroups = outputObjectsGroups;
 }
예제 #12
0
 public BuildTransaction(IAssetIndexMap assetIndexMap, IEnumerable <IDictionary <ObjectUrl, OutputObject> > outputObjectsGroups)
 {
     this.assetIndexMap       = assetIndexMap;
     this.outputObjectsGroups = outputObjectsGroups;
 }
예제 #13
0
 public abstract IEnumerable<string> Select(PackageSession packageSession, IAssetIndexMap assetIndexMap);
예제 #14
0
 /// <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());
 }
예제 #15
0
 public DatabaseFileProvider(IAssetIndexMap assetIndexMap, ObjectDatabase objectDatabase, string mountPoint = null) : base(mountPoint)
 {
     this.assetIndexMap = assetIndexMap;
     this.objectDatabase = objectDatabase;
 }
 /// <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());
 }