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;
List<KeyValuePair<string, string>> extensions = new List<KeyValuePair<string,string>>();
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;
else
extensions.Add(p);
}
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;
foreach (var extension in extensions)
link.SetLinkExtension(extension.Key, extension.Value);
if (!String.IsNullOrEmpty(type)) link.Type = type;
return link;
}