public ActionResourceLink <TResource> BuildResourceUrl(HttpMethod httpMethod, Expression <Func <TResource, string> > resourceUrl) { if (resourceUrl == null) { throw new ArgumentNullException(nameof(resourceUrl), "Resource Delegate not specified."); } var actionLink = new ActionResourceLink <TResource>(resourceUrl); var linkDescriptor = new LinkDescriptor <TResource>(actionLink); linkDescriptor.SetMethod(httpMethod); return(actionLink); }
public StringFormattedLink <TResource> BuildResourceUrl(HttpMethod httpMethod, Expression <Func <TResource, string> > resourceUrl) { if (resourceUrl == null) { throw new ArgumentNullException(nameof(resourceUrl), "Resource Delegate cannot be null."); } var resourceLink = new StringFormattedLink <TResource>(resourceUrl); var linkDescriptor = new LinkDescriptor <TResource>(resourceLink); linkDescriptor.SetMethod(httpMethod); return(resourceLink); }
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); }
/// <summary> /// Create a named link related for a parametrized URI containing place holds based on /// resource properties to be substituted at link resolution time. /// </summary> /// <param name="relName">The relation name.</param> /// <param name="httpMethod">The HTTP method used to invoke URI.</param> /// <param name="resourceUrl">Function delegate passed the resource during link resolution and /// returns a populated URI or partial populated URI (i.e. Template) based on the properties /// of the passed resourced.</param> /// <returns>Object used to add optional metadata to the created link.</returns> public LinkDescriptor <TResource> Href(string relName, HttpMethod httpMethod, Expression <Func <TResource, string> > resourceUrl) { if (string.IsNullOrWhiteSpace(relName)) { throw new ArgumentException("Relation Name not specified.", nameof(relName)); } if (resourceUrl == null) { throw new ArgumentNullException(nameof(resourceUrl), "Resource Delegate not specified."); } var actionLink = new ActionResourceLink <TResource>(resourceUrl); var linkDescriptor = new LinkDescriptor <TResource>(actionLink); AddActionLink(actionLink); linkDescriptor.SetRelName(relName); linkDescriptor.SetMethod(httpMethod); return(linkDescriptor); }
//--------- 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); }