Exemple #1
0
            internal override IEnumerable <string> Enumerate(IEnumerable <string> items,
                                                             GlobController enumerator)
            {
                string deviceName = (device + ":" + "/");

                return(new [] { deviceName });
            }
Exemple #2
0
            internal override IEnumerable <string> Enumerate(IEnumerable <string> items,
                                                             GlobController enumerator)
            {
                var result = items.SelectMany(t => enumerator.EnumerateFileSystemEntries(t)).Where(t => regex.IsMatch(t));

                return(result);
            }
Exemple #3
0
 private Glob(string text, SegmentSequence[] segments)
 {
     _text       = text;
     _segments   = segments;
     _regexCache = new Lazy <Regex>(MakeRegex);
     _controller = new GlobController();
 }
Exemple #4
0
            internal override IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                            GlobController enumerator) {
                foreach (Segment s in this.segments) {
                    items = s.Enumerate(items, enumerator);
                }

                return items;
            }
Exemple #5
0
            internal override IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                            GlobController enumerator) {

                Queue<string> results = new Queue<string>(enumerator.OnlyDirectories(items));
                while (results.Count > 0) {
                    var item = results.Dequeue();
                    yield return item;

                    var descendents = enumerator.EnumerateDirectories(item);
                    foreach (var d in descendents)
                        results.Enqueue(d);
                }
            }
Exemple #6
0
        static Exception _TryParse(string text, GlobController controller, out Glob value) {
            text = controller.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;
        }
Exemple #7
0
        internal static IEnumerable<string> FilterDirectory(Glob glob,
                                                            string directory,
                                                            Predicate<string> match,
                                                            GlobController enumerator) {

            var items = Enumerable.Empty<string>();
            IEnumerable<string> subItemsStart = new[] { enumerator.ExpandEnvironmentVariables(directory) };
            foreach (SegmentSequence sub in glob._segments) {
                var subItems = sub.Enumerate(subItemsStart, enumerator);
                items = items.Concat(subItems);
            }

            return items
                .Where(t => match(t))
                .Distinct();
        }
Exemple #8
0
        protected Glob(string text, Glob.GlobController controller)
        {
            if (controller == null)
            {
                controller = new GlobController();
            }
            text = controller.ExpandEnvironmentVariables(text);
            Exception ex = _TryParse(text, out _segments);

            if (ex != null)
            {
                throw ex;
            }
            _text       = text;
            _regexCache = new Lazy <Regex>(MakeRegex);
            _controller = controller;
        }
Exemple #9
0
            internal override IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                            GlobController enumerator) {

                return items.SelectMany(t => enumerator.EnumerateDirectories(t));
            }
Exemple #10
0
            internal override IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                            GlobController enumerator) {

                return new [] { "/" };
            }
Exemple #11
0
 internal override IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                 GlobController enumerator) {
     return items.Where(t => enumerator.DirectoryExists(t));
 }
Exemple #12
0
 internal abstract IEnumerable<string> Enumerate(IEnumerable<string> items,
                                                 GlobController enumerator);