Created
April 1, 2015 16:11
-
-
Save darrelmiller/deff3525791be6470520 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TavisUriTemplateHandler : IUrlTemplateHandler | |
{ | |
public IEnumerable<string> GetParameterNames(string template) | |
{ | |
return new UriTemplate(template).GetParameterNames(); | |
} | |
public Uri GetRequestUri(IUrlParameterFormatter urlParameterFormatter, RestMethodInfo restMethod, object[] paramList, string basePath = "") | |
{ | |
string urlTarget = (basePath == "/" ? String.Empty : basePath) + restMethod.RelativePath; | |
var template = new UriTemplate(urlTarget); | |
for (int i = 0; i < paramList.Length; i++) | |
{ | |
if (restMethod.ParameterMap.ContainsKey(i)) | |
{ | |
template.AddParameter(restMethod.ParameterMap[i], urlParameterFormatter.Format(paramList[i], restMethod.ParameterInfoMap[i])); | |
} | |
} | |
return new Uri(template.Resolve(), UriKind.RelativeOrAbsolute); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment