public string GetUrl(XmlElement linkElement)
{
string linkName = this.Context.ProcessText(linkElement.GetAttribute("ref"));
string linkValues = this.Context.ProcessText(linkElement.GetAttribute("values"));
string linkHash = this.Context.ProcessText(linkElement.GetAttribute("hash"));
bool urlEncode = linkElement.GetAttribute("encode").ContainsAnyOf("yes", "true", "1");
bool qualify = linkElement.GetAttribute("absolute").ContainsAnyOf("yes", "true", "1");
string linkHref = null;
if (!string.IsNullOrEmpty(linkName))
{
linkHref = this.GetUrl(linkName, linkValues, linkHash, qualify);
if (!string.IsNullOrWhiteSpace(linkHash))
{
int hashIndex = linkHref.IndexOf("#", System.StringComparison.Ordinal);
if (hashIndex != -1)
linkHref = linkHref.Substring(0, hashIndex);
linkHref = string.Concat(linkHref, "#", linkHash.Trim('#'));
}
}
if (urlEncode && !string.IsNullOrEmpty(linkHref))
linkHref = HttpUtility.UrlEncode(linkHref);
return linkHref;
}