本文整理汇总了C#中Operation.GenerateSampleODataUri方法的典型用法代码示例。如果您正苦于以下问题:C# Operation.GenerateSampleODataUri方法的具体用法?C# Operation.GenerateSampleODataUri怎么用?C# Operation.GenerateSampleODataUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation.GenerateSampleODataUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHttpRequestMessage
private static HttpRequestMessage CreateHttpRequestMessage(HttpMethod httpMethod, Operation potentialOperation, SwaggerRoute potentialSwaggerRoute, HttpConfiguration httpConfig)
{
Contract.Requires(httpConfig != null);
Contract.Requires(potentialSwaggerRoute != null);
Contract.Ensures(Contract.Result<HttpRequestMessage>() != null);
Contract.Assume(potentialSwaggerRoute.ODataRoute.Constraints != null);
var oDataAbsoluteUri = potentialOperation.GenerateSampleODataUri(ServiceRoot, potentialSwaggerRoute.PrefixedTemplate);
var httpRequestMessage = new HttpRequestMessage(httpMethod, oDataAbsoluteUri);
var odataPath = GenerateSampleODataPath(potentialOperation, potentialSwaggerRoute);
var requestContext = new HttpRequestContext
{
Configuration = httpConfig
};
httpRequestMessage.SetConfiguration(httpConfig);
httpRequestMessage.SetRequestContext(requestContext);
var oDataRoute = potentialSwaggerRoute.ODataRoute;
var httpRequestMessageProperties = httpRequestMessage.ODataProperties();
Contract.Assume(httpRequestMessageProperties != null);
httpRequestMessageProperties.Model = oDataRoute.GetEdmModel();
httpRequestMessageProperties.Path = odataPath;
httpRequestMessageProperties.RouteName = oDataRoute.GetODataPathRouteConstraint().RouteName;
httpRequestMessageProperties.RoutingConventions = oDataRoute.GetODataPathRouteConstraint().RoutingConventions;
httpRequestMessageProperties.PathHandler = oDataRoute.GetODataPathRouteConstraint().PathHandler;
httpRequestMessage.SetRouteData(oDataRoute.GetRouteData("/", httpRequestMessage));
return httpRequestMessage;
}
示例2: GenerateSampleODataPath
private static ODataPath GenerateSampleODataPath(Operation operation, SwaggerRoute swaggerRoute)
{
Contract.Requires(operation != null);
Contract.Requires(swaggerRoute != null);
Contract.Requires(swaggerRoute.ODataRoute.Constraints != null);
Contract.Ensures(Contract.Result<ODataPath>() != null);
var oDataPathRouteConstraint = swaggerRoute.ODataRoute.GetODataPathRouteConstraint();
var model = swaggerRoute.ODataRoute.GetEdmModel();
Contract.Assume(oDataPathRouteConstraint.PathHandler != null);
var odataPath = operation.GenerateSampleODataUri(ServiceRoot, swaggerRoute.Template).Replace(ServiceRoot, string.Empty);
var result = oDataPathRouteConstraint.PathHandler.Parse(model, ServiceRoot, odataPath);
Contract.Assume(result != null);
return result;
}