Open.Core.Css.GetLink C# (CSharp) Method

GetLink() public static method

Retrieves the CSS with the given source (src) URL.
public static GetLink ( string url ) : Element
url string The path to the CSS document to match (not case-sensitive).
return System.Html.Element
        public static Element GetLink(string url)
        {
            // Setup initial conditions.
            if (!Helper.String.HasValue(url)) return null;
            url = url.ToLowerCase().Trim();

            // Enumerate the colleciton of items.
            foreach (Element link in jQuery.Select("link[type='text/css']").GetElements())
            {
                ElementAttribute href = link.GetAttributeNode(Html.Href);
                if (Script.IsNullOrUndefined(href)) continue;
                if (url == href.Value.ToLowerCase().Trim()) return link;
            }

            // Not Found: check if the CSS file is referenced with a fully-qualified domain.
            if (!url.StartsWith("http"))
            {
                Element link = GetLink(Helper.Url.PrependDomain(url));
                if (link != null) return link;
            }

            // Finish up (Not Found).
            return null;
        }
        #endregion