コード例 #1
0
        public ActionLink BuildUrl(HttpMethod httpMethod, string href)
        {
            if (string.IsNullOrWhiteSpace(href))
            {
                throw new ArgumentException("HREF value not specified.", nameof(href));
            }

            var actionLink     = new ActionLink();
            var linkDescriptor = new LinkDescriptor <TResource>(actionLink);

            linkDescriptor.SetHref(href);
            linkDescriptor.SetMethod(httpMethod);
            return(actionLink);
        }
コード例 #2
0
        //--------- STRING BASED LINKS ------------------------------------------

        /// <summary>
        /// Creates a named link relation for a hard-coded URI value.
        /// </summary>
        /// <param name="relName">The relation name.</param>
        /// <param name="href">The URI associated with the relation.</param>
        /// <param name="httpMethod">The HTTP method used to invoke the URI.</param>
        /// <returns>Object used to add optional metadata to the created link.</returns>
        public LinkDescriptor <TResource> Href(string relName, HttpMethod httpMethod, string href)
        {
            if (string.IsNullOrWhiteSpace(relName))
            {
                throw new ArgumentException("Relation Name not specified.", nameof(relName));
            }
            if (string.IsNullOrWhiteSpace(href))
            {
                throw new ArgumentException("HREF value not specified.", nameof(href));
            }

            var resourceLink   = new ResourceLink();
            var linkDescriptor = new LinkDescriptor <TResource>(resourceLink);

            AddResourceLink(resourceLink);

            linkDescriptor.SetRelName(relName);
            linkDescriptor.SetHref(href);
            linkDescriptor.SetMethod(httpMethod);

            return(linkDescriptor);
        }