Example #1
0
        /// <summary>
        /// Returns all projects that regex match both the provided package name and commands
        /// </summary>
        /// <remarks>
        /// If commands is null, any script command will match.
        /// </remarks>
        /// <exception cref="System.ArgumentException">A regular expression parsing error occurred</exception>
        public IReadOnlyCollection <JavaScriptProject> GetMatches(IJavaScriptProjectRegexSelector regexSelector)
        {
            var packageRegex = new Regex(regexSelector.PackageNameRegex, RegexOptions.None);
            var packages     = m_nameToProjects.Keys.Where(projectName => packageRegex.IsMatch(projectName));

            var commandRegex = regexSelector.CommandRegex != null ? new Regex(regexSelector.CommandRegex, RegexOptions.None) : null;

            var matches = new List <JavaScriptProject>();

            foreach (string packageName in packages)
            {
                var projects = m_nameToProjects[packageName];

                if (commandRegex == null)
                {
                    matches.AddRange(projects);
                }
                else
                {
                    matches.AddRange(projects.Where(project => commandRegex.IsMatch(project.ScriptCommandName)));
                }
            }

            return(matches);
        }
 /// <nodoc />
 public JavaScriptProjectRegexSelector(IJavaScriptProjectRegexSelector template)
 {
     PackageNameRegex = template.PackageNameRegex;
     CommandRegex     = template.CommandRegex;
 }