Beispiel #1
0
        static Exception _TryParseList(string text, out IteratedSegmentSequence segments)
        {
            segments = null;
            string[]       items   = text.Split('/', '\\');
            List <Segment> results = new List <Segment>(items.Length);

            foreach (string s in items)
            {
                Segment sgt;
                if (s.Length == 0)
                {
                    // TODO Only apply at real root; enforce match segment as file or directory
                    sgt = new RootSegment();
                }
                else if (DEVICE.IsMatch(s))
                {
                    sgt = new DeviceSegment(DEVICE.Match(s).Groups["Name"].Value);
                }
                else if (s == "*")
                {
                    sgt = new AnyDirectorySegment();
                }
                else if (s == "**")
                {
                    sgt = new RecursiveSegment();

                    // TODO Support directory navigation
                }
                else if (s == "..")
                {
                    throw new NotImplementedException();
                }
                else if (s == ".")
                {
                    sgt = new CwdSegment();
                }
                else
                {
                    string segment = ExpandSegment(s);
                    if (segment == null)
                    {
                        return(SpecFailure.NotParsable("text", typeof(Glob)));
                    }

                    sgt = new MatchSegment(segment);
                }

                results.Add(sgt);
            }

            segments = new IteratedSegmentSequence(results.ToArray());
            return(null);
        }
        static Exception _TryParseList(string text, out IteratedSegmentSequence segments)
        {
            segments = null;
            string[] items = text.Split('/', '\\');
            List<Segment> results = new List<Segment>(items.Length);

            foreach (string s in items) {
                Segment sgt;
                if (s.Length == 0) {
                    // TODO Only apply at real root; enforce match segment as file or directory
                    sgt = new RootSegment();

                } else if (DEVICE.IsMatch(s)) {
                    sgt = new DeviceSegment(DEVICE.Match(s).Groups["Name"].Value);

                } else if (s == "*") {
                    sgt = new AnyDirectorySegment();

                } else if (s == "**") {
                    sgt = new RecursiveSegment();

                    // TODO Support directory navigation
                } else if (s == "..") {
                    throw new NotImplementedException();

                } else if (s == ".") {
                    throw new NotImplementedException();

                } else {
                    string segment = ExpandSegment(s);
                    if (segment == null)
                        return Failure.NotParsable("text", typeof(Glob));

                    sgt = new MatchSegment(segment);
                }

                results.Add(sgt);
            }

            segments = new IteratedSegmentSequence(results.ToArray());
            return null;
        }
 public MatchEventCommentary(MatchEventType EventType, string RawText, MatchSegment Segment)
 {
     this.EventType = EventType;
     this.RawText   = RawText;
     this.Segment   = Segment;
 }