本文整理汇总了C#中System.Web.Http.Description.ApiDescription.ActualResponseType方法的典型用法代码示例。如果您正苦于以下问题:C# ApiDescription.ActualResponseType方法的具体用法?C# ApiDescription.ActualResponseType怎么用?C# ApiDescription.ActualResponseType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Description.ApiDescription
的用法示例。
在下文中一共展示了ApiDescription.ActualResponseType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApiDescriptionToOperation
public Operation ApiDescriptionToOperation(ApiDescription apiDescription, Dictionary<string, DataType> complexModels)
{
var apiPath = apiDescription.RelativePathSansQueryString();
var parameters = apiDescription.ParameterDescriptions
.Select(paramDesc => CreateParameter(paramDesc, apiPath, complexModels))
.ToList();
var operation = new Operation
{
Method = apiDescription.HttpMethod.Method,
Nickname = apiDescription.Nickname(),
Summary = apiDescription.Documentation,
Parameters = parameters,
ResponseMessages = new List<ResponseMessage>()
};
var responseType = apiDescription.ActualResponseType();
if (responseType == null)
{
operation.Type = "void";
}
else
{
IDictionary<string, DataType> complexModelsForResponseType;
var dataType = _dataTypeGenerator.TypeToDataType(responseType, out complexModelsForResponseType);
complexModels.Merge(complexModelsForResponseType);
if (dataType.Type == "object")
{
operation.Type = dataType.Id;
}
else
{
operation.Type = dataType.Type;
operation.Format = dataType.Format;
operation.Items = dataType.Items;
operation.Enum = dataType.Enum;
}
}
foreach (var filter in _operationFilters)
{
filter.Apply(operation, complexModels, _dataTypeGenerator, apiDescription);
}
return operation;
}
示例2: ApiDescriptionToOperation
public Operation ApiDescriptionToOperation(ApiDescription apiDescription)
{
var apiPath = apiDescription.RelativePathSansQueryString();
var parameters = apiDescription.ParameterDescriptions
.Select(paramDesc => CreateParameter(paramDesc, apiPath))
.ToList();
var operation = new Operation
{
Method = apiDescription.HttpMethod.Method,
Nickname = apiDescription.Nickname(),
Summary = apiDescription.Documentation ?? "",
Parameters = parameters,
ResponseMessages = new List<ResponseMessage>(),
Produces = apiDescription.SupportedResponseFormatters.SelectMany(d => d.SupportedMediaTypes.Select(t => t.MediaType)).ToList(),
Consumes = apiDescription.SupportedRequestBodyFormatters.SelectMany(d => d.SupportedMediaTypes.Select(t => t.MediaType)).ToList()
};
var responseType = apiDescription.ActualResponseType();
if (responseType == null)
{
operation.Type = "void";
}
else
{
var dataType = _dataTypeRegistry.GetOrRegister(responseType);
if (dataType.Type == "object")
{
operation.Type = dataType.Id;
}
else
{
operation.Type = dataType.Type;
operation.Format = dataType.Format;
operation.Items = dataType.Items;
operation.Enum = dataType.Enum;
}
}
foreach (var filter in _operationFilters)
{
filter.Apply(operation, _dataTypeRegistry, apiDescription);
}
return operation;
}