예제 #1
0
        private void Produces(IFilterModel model)
        {
            switch (_options.Value.ApiFormats)
            {
            case ApiSupportedMediaTypes.None:
                throw new NotSupportedException(_localizer.GetString("API must support at least one content format"));

            case ApiSupportedMediaTypes.ApplicationJson | ApiSupportedMediaTypes.ApplicationXml:
                model.Produces(ApiMediaTypeNames.Application.Json, ApiMediaTypeNames.Application.Xml);
                break;

            case ApiSupportedMediaTypes.ApplicationJson:
                model.Produces(ApiMediaTypeNames.Application.Json);
                break;

            case ApiSupportedMediaTypes.ApplicationXml:
                model.Produces(ApiMediaTypeNames.Application.Xml);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }