當前位置: 首頁>>代碼示例>>C#>>正文


C# ApiDescription.ActualResponseType方法代碼示例

本文整理匯總了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;
        }
開發者ID:kevynb,項目名稱:Swashbuckle,代碼行數:48,代碼來源:OperationGenerator.cs

示例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;
        }
開發者ID:AnthonyNeace,項目名稱:Swashbuckle,代碼行數:46,代碼來源:OperationGenerator.cs


注:本文中的System.Web.Http.Description.ApiDescription.ActualResponseType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。