// "Therefore those skilled at the unorthodox // are infinite as heaven and earth, // inexhaustible as the great rivers. // When they come to an end, // they begin again, // like the days and months; // they die and are reborn, // like the four seasons." // // - Sun Tsu, // "The Art of War" namespace TheArtOfDev.HtmlRenderer.Core.Entities { /// /// Holds data on link element in HTML.
/// Used to expose data outside of HTML Renderer internal structure. ///
public sealed class LinkElementData { /// /// the id of the link element if present /// private readonly string _id; /// /// the href data of the link /// private readonly string _href; /// /// the rectangle of element as calculated by html layout /// private readonly T _rectangle; /// /// Init. /// public LinkElementData(string id, string href, T rectangle) { _id = id; _href = href; _rectangle = rectangle; } /// /// the id of the link element if present /// public string Id { get { return _id; } } /// /// the href data of the link /// public string Href { get { return _href; } } /// /// the rectangle of element as calculated by html layout /// public T Rectangle { get { return _rectangle; } } /// /// Is the link is directed to another element in the html /// public bool IsAnchor { get { return _href.Length > 0 && _href[0] == '#'; } } /// /// Return the id of the element this anchor link is referencing. /// public string AnchorId { get { return IsAnchor && _href.Length > 1 ? _href.Substring(1) : string.Empty; } } /// /// /// /// public override string ToString() { return string.Format("Id: {0}, Href: {1}, Rectangle: {2}", _id, _href, _rectangle); } } }