本文整理汇总了C#中System.Web.Http.Description.ApiDescription.GetFriendlyId方法的典型用法代码示例。如果您正苦于以下问题:C# ApiDescription.GetFriendlyId方法的具体用法?C# ApiDescription.GetFriendlyId怎么用?C# ApiDescription.GetFriendlyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Description.ApiDescription
的用法示例。
在下文中一共展示了ApiDescription.GetFriendlyId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPostmanDatas
private List<PostmanData> GetPostmanDatas(ApiDescription api)
{
var postmandatas = new List<PostmanData>();
var apiModel = Configuration.GetHelpPageApiModel(api.GetFriendlyId());
var raw = apiModel.SampleRequests.Values.FirstOrDefault();
if (raw == null) return postmandatas;
var pdata = JsonConvert.DeserializeObject<Dictionary<string,string>>(raw.ToString());
postmandatas.AddRange(pdata.Select(model => new PostmanData {key = model.Key, value = model.Value}));
return postmandatas;
}
示例2: GetApiInfo
private static ApiInfo GetApiInfo(ApiDescription desc)
{
var api = new ApiInfo() { Name = desc.GetFriendlyId() };
api.Method = desc.HttpMethod.Method;
api.Route = GetRoute(desc);
api.RouteParameters = GetRouteParameters(desc);
api.QueryParameters = GetQueryParameters(desc);
api.BodyParameter = GetBodyParameter(desc);
api.ComplexTypes = GetComplexTypes(api.BodyParameter);
return api;
}
示例3: ParseResponse
public static void ParseResponse(Trace trace, HttpResponseMessage response)
{
try
{
var responseBody = response.Content;
trace.Response = responseBody.ReadAsStringAsync().Result;
trace.Status = ((int)response.StatusCode).ToString();
if (trace.Response.Length > 0 && !trace.Status.Equals("429"))
{
trace.ResponseBodyLength = responseBody.Headers.ContentLength;
var ad = response.RequestMessage.GetActionDescriptor();
if (ad != null)
{
var action = new ApiDescription
{
HttpMethod = response.RequestMessage.Method,
RelativePath = response.RequestMessage.RequestUri.PathAndQuery.Substring(1)
};
var fid = action.GetFriendlyId();
trace.FriendlyURI = APIUriList.FirstOrDefault(x => x.Equals(fid, StringComparison.OrdinalIgnoreCase));
if (string.IsNullOrWhiteSpace(trace.FriendlyURI))
trace.FriendlyURI = APIUriList.FirstOrDefault(x => x.StartsWith(fid, StringComparison.OrdinalIgnoreCase));
trace.Action = ad.ControllerDescriptor.ControllerName + " / " + ad.ActionName;
}
if (TraceList.Count >= 64)
TraceList.RemoveAt(0);
TraceList.Add(trace);
}
}
catch (Exception)
{
}
}