示例#1
0
 /// <summary>
 /// Попробовать распарсить ссылку.
 /// </summary>
 /// <param name="uri">URI.</param>
 /// <returns>Ссылка.</returns>
 public BoardLinkBase TryParsePostLink(string uri)
 {
     try
     {
         var regexes = new Regex[] { PostLinkRegex, PostLinkRegex2 };
         var match = regexes.Select(r => r.Match(uri)).FirstOrDefault(r => r.Success);
         if (match != null)
         {
             if (match.Groups["post"].Captures.Count > 0)
             {
                 return new PostLink()
                 {
                     Engine = CoreConstants.Engine.Makaba,
                     Board = match.Groups["board"].Captures[0].Value,
                     Thread = int.Parse(match.Groups["parent"].Captures[0].Value),
                     Post = int.Parse(match.Groups["post"].Captures[0].Value)
                 };
             }
             return new ThreadLink()
             {
                 Engine = CoreConstants.Engine.Makaba,
                 Board = match.Groups["board"].Captures[0].Value,
                 Thread = int.Parse(match.Groups["parent"].Captures[0].Value),
             };
         }
         return null;
     }
     catch (Exception ex)
     {
         return null;
     }
 }