Hapikit.Links.LinkHeaderParser.ParseLink C# (CSharp) Method

ParseLink() protected method

protected ParseLink ( ) : ILink
return ILink
    protected ILink ParseLink()
    {
//      Condition.Requires(NextToken.Type, "CurrentToken.Type").IsEqualTo(TokenType.Url);

      string url = NextToken.Value;
      string rel = null;
      string title = null;
      string title_s = null;
      string type = null;

      GetNextToken();

      while (NextToken.Type == TokenType.Semicolon)
      {
        try
        {
          GetNextToken();
          bool isExtended;
          KeyValuePair<string, string> p = ParseParameter(out isExtended);

          if (p.Key == "rel" && rel == null)
            rel = p.Value;
          else if (p.Key == "title" && title == null && !isExtended)
            title = p.Value;
          else if (p.Key == "title" && title_s == null && isExtended)
            title_s = p.Value;
          else if (p.Key == "type" && type == null)
            type = p.Value;
        }
        catch (FormatException)
        {
          while (NextToken.Type != TokenType.Semicolon && NextToken.Type != TokenType.Comma && NextToken.Type != TokenType.EOF)
          {
            try
            {
              GetNextToken();
            }
            catch (FormatException)
            {
            }
          }
        }
      }

        ILink link = _linkFactory.CreateLink(rel);
        link.Target = new Uri(BaseUrl, url);
        link.Relation = rel;
        link.Title=  title_s ?? title;
    
        if (!String.IsNullOrEmpty(type)) link.Type = type;
      return link;
    }