public IEnumerable <InsqlDescriptor> GetDescriptors()
        {
            IEnumerable <Assembly> assemblies = this.options.Value.Assemblies;

            if (assemblies == null || assemblies.Count() < 1)
            {
                assemblies = AppDomain.CurrentDomain.GetAssemblies();
            }

            return(assemblies
                   .Where(assembly => !assembly.IsDynamic && !assembly.ReflectionOnly)
                   .SelectMany(assembly =>
            {
                var resourceNames = assembly.GetManifestResourceNames();

                resourceNames = GlobHelper.Filter(resourceNames, this.options.Value.Locations, new GlobOptions
                {
                    AllowWindowsPaths = true
                }).ToArray();

                return resourceNames.Select(name =>
                {
                    return this.ParseDescriptor(assembly.GetManifestResourceStream(name));
                }).Where(o => o != null);
            }).ToList());
        }
Exemple #2
0
        ///<summary>Filters a list of inputs against a single pattern.</summary>
        ///<remarks>This function reparses this input on each invocation.  For performance, avoid this function and reuse a Minimatcher instance instead.</remarks>
        public static IEnumerable <string> Filter(IEnumerable <string> list, string pattern, GlobOptions options = null)
        {
            var mm = new GlobHelper(pattern, options);

            list = list.Where(mm.IsMatch);
            if (options != null && options.NoNull)
            {
                list = list.DefaultIfEmpty(pattern);
            }
            return(list);
        }
Exemple #3
0
        ///<summary>Creates a filter function that tests input against a pattern.</summary>
        public static Func <string, bool> CreateFilter(string pattern, GlobOptions options = null)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            // "" only matches ""
            if (String.IsNullOrWhiteSpace(pattern))
            {
                return(String.IsNullOrEmpty);
            }

            var m = new GlobHelper(pattern, options);

            return(m.IsMatch);
        }