public IteratedSegmentSequence(Glob.Segment[] segments)
 {
     this.segments = segments;
 }
            public FileObject(Glob.FileSystemEntity type, string name, IEnumerable<FileObject> files)
            {
                this.Name = name;
                this.Type = type;

                if (files != null) {
                    foreach (var file in files)
                        this.Files.Add(file);
                }
            }
 internal static IEnumerable<string> FilterFiles(Glob glob, IEnumerable<string> files)
 {
     var regex = glob.ToRegex();
     return files.Select(t => ExpandEnvironmentVariables(t)).Where(t => regex.IsMatch(t));
 }
        static Exception _TryParse(string text, out Glob value)
        {
            text = ExpandEnvironmentVariables(text);

            SegmentSequence[] segments;
            Exception ex = _TryParse(text, out segments);
            value = null;

            if (ex == null) {
                value = new Glob(text, segments);
                return null;
            } else
                return ex;
        }
        internal static IEnumerable<string> FilterDirectories(Glob glob,
                                                              IEnumerable<string> directories,
                                                              FileSystemEntity resultType,
                                                              FileSystemEnumerator enumerator)
        {
            IEnumerable<Item> items = Enumerable.Empty<Item>();
            IEnumerable<Item> subItemsStart = directories.Select(
                t => new Item(ExpandEnvironmentVariables(t), FileSystemEntity.Directory)).ToArray();
            foreach (SegmentSequence sub in glob.segments) {

                IEnumerable<Item> subItems = subItemsStart;
                subItems = sub.Enumerate(subItems, enumerator);

                items = items.Concat(subItems);
            }

            // TODO Should inform the last segment of the result type rather than filter here
            return items
                .Where(t => t.Item2 == resultType)
                .Select(t => t.Item1)
                .Distinct();
        }
 public static bool TryParse(string text, out Glob value)
 {
     return _TryParse(text, out value) == null;
 }
        public static Glob Combine(Glob arg1, Glob arg2, Glob arg3)
        {
            if (arg1 == null)
                throw new ArgumentNullException("arg1");

            if (arg2 == null)
                throw new ArgumentNullException("arg2");

            if (arg3 == null)
                throw new ArgumentNullException("arg3");

            return Combine(arg1, Combine(arg2, arg3));
        }
        public static Glob Combine(Glob arg1, Glob arg2)
        {
            if (arg1 == null)
                throw new ArgumentNullException("arg1");

            if (arg2 == null)
                throw new ArgumentNullException("arg2");

            if (object.ReferenceEquals(arg1, arg2))
                return arg1;

            if (arg1.IsAnything || arg2.IsAnything)
                return Glob.Anything;

            return new Glob(arg1.text + ";" + arg2.text,
                            arg1.segments.Concat(arg2.segments).ToArray<SegmentSequence>());
        }
Пример #9
0
        static bool StaticEquals(Glob lhs, Glob rhs)
        {
            if (ReferenceEquals(lhs, rhs))
                return true;
            if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
                return false;

            return lhs.text == rhs.text;
        }