Ejemplo n.º 1
0
        public PathTemplateProcessor(string path)
        {
            var segments = new List<PathSegment>();
            var searchPath = new List<string>();
            var pathSegments = path.Split(new[] { '/', '\\' });

            if (pathSegments[0] != "**")
                segments.Add(new WildcardPathSegment());

            foreach (var seg in pathSegments)
            {
                var templateSegment = TemplatePathSegment.TryParse(seg);
                PathSegment segment;
                string searchSegment;
                if (seg == "**")
                {
                    segment = new WildcardPathSegment();
                    searchSegment = "**";
                }
                else if (templateSegment != null)
                {
                    segment = templateSegment;
                    searchSegment = "*";
                }
                else
                {
                    segment = new LiteralPathSegment(seg);
                    searchSegment = seg;
                }
                segments.Add(segment);
                searchPath.Add(searchSegment);
            }
            _segments = new LinkedList<PathSegment>(segments);
            _searchString = searchPath.Join(System.IO.Path.DirectorySeparatorChar);
        }
Ejemplo n.º 2
0
        public PathTemplateProcessor(string path)
        {
            var segments     = new List <PathSegment>();
            var searchPath   = new List <string>();
            var pathSegments = path.Split(new[] { '/', '\\' });

            if (pathSegments[0] != "**")
            {
                segments.Add(new WildcardPathSegment());
            }

            foreach (var seg in pathSegments)
            {
                var         templateSegment = TemplatePathSegment.TryParse(seg);
                PathSegment segment;
                string      searchSegment;
                if (seg == "**")
                {
                    segment       = new WildcardPathSegment();
                    searchSegment = "**";
                }
                else if (templateSegment != null)
                {
                    segment       = templateSegment;
                    searchSegment = "*";
                }
                else
                {
                    segment       = new LiteralPathSegment(seg);
                    searchSegment = seg;
                }
                segments.Add(segment);
                searchPath.Add(searchSegment);
            }
            _segments     = new LinkedList <PathSegment>(segments);
            _searchString = searchPath.Join(System.IO.Path.DirectorySeparatorChar);
        }