Exemplo n.º 1
0
 private void ExtractSegments()
 {
     // TODO : validation of segments (for example the match-all segment should be the last of a section)
     SchemeSegment = SchemePattern;
     hostSegments  = HostPattern == "" ? new string[0] : HostPattern.Split(HostSeparator).ToArray();
     pathSegments  = PathPattern == "" ? new string[0] : PathPattern.Split(PathDelimiter).ToArray();
     QuerySegments = QueryPattern == ""
                                         ? Enumerable.Empty <KeyValuePair <string, string> >()
                                         : QueryPattern.Split(QuerySeparator)
                     .Select(x => new Tuple <string, int>(x, x.IndexOf('=')))
                     .Where(t => t.Item2 > 0)
                     .Select(t =>
     {
         string varName  = t.Item1.Substring(0, t.Item2);
         string varValue = t.Item1.Substring(t.Item2 + 1);
         return(new KeyValuePair <string, string>(varName, varValue));
     })
                     .ToList();
 }