Exemplo n.º 1
0
        /// <inheritdoc/>
        public override IEnumerable<string> Select(PackageSession packageSession, IContentIndexMap contentIndexMap)
        {
            // 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 contentIndexMap.GetMergedIdMap()
                .Select(asset => asset.Key) // Select url
                .Where(assetUrl => regexes.Any(regex => regex.Value.IsMatch(assetUrl))); // Check if any Regex matches
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override IEnumerable <string> Select(PackageSession packageSession, IContentIndexMap contentIndexMap)
        {
            // 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(contentIndexMap.GetMergedIdMap()
                   .Select(asset => asset.Key)                                               // Select url
                   .Where(assetUrl => regexes.Any(regex => regex.Value.IsMatch(assetUrl)))); // Check if any Regex matches
        }
 /// <summary>
 /// Merges the values from the given asset index map.
 /// </summary>
 /// <param name="contentIndexMap">The asset index map to merge.</param>
 public void Merge(IContentIndexMap contentIndexMap)
 {
     Merge(contentIndexMap.GetMergedIdMap());
 }
 /// <summary>
 /// Merges the values from the given asset index map.
 /// </summary>
 /// <param name="contentIndexMap">The asset index map to merge.</param>
 public void Merge(IContentIndexMap contentIndexMap)
 {
     Merge(contentIndexMap.GetMergedIdMap());
 }