本文整理汇总了C#中HttpConfiguration.SetEdmModel方法的典型用法代码示例。如果您正苦于以下问题:C# HttpConfiguration.SetEdmModel方法的具体用法?C# HttpConfiguration.SetEdmModel怎么用?C# HttpConfiguration.SetEdmModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpConfiguration
的用法示例。
在下文中一共展示了HttpConfiguration.SetEdmModel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetEdmModel_WithADifferentModel_AfterSettingFormatter_Throws
public void SetEdmModel_WithADifferentModel_AfterSettingFormatter_Throws()
{
// Arrange
HttpConfiguration config = new HttpConfiguration();
IEdmModel model = new Mock<IEdmModel>().Object;
config.SetODataFormatter(new ODataMediaTypeFormatter());
// Act
Assert.Throws<NotSupportedException>(
() => config.SetEdmModel(model),
"The given 'IEdmModel' does not match the 'IEdmModel' in the formatter on the configuration. Setting 'ODataMediaTypeFormatter' using the method 'SetODataFormatter' also sets the corresponding 'IEdmModel'.");
}
示例2: GetODataPathHandlerReturnsDefaultPathHandlerByDefault
public void GetODataPathHandlerReturnsDefaultPathHandlerByDefault()
{
HttpConfiguration config = new HttpConfiguration();
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Customer>(typeof(Customer).Name);
IEdmModel model = modelBuilder.GetEdmModel();
config.SetEdmModel(model);
var pathHandler = config.GetODataPathHandler();
Assert.NotNull(pathHandler);
Assert.IsType<DefaultODataPathHandler>(pathHandler);
}
示例3: SetEdmModelThenGetReturnsWhatYouSet
public void SetEdmModelThenGetReturnsWhatYouSet()
{
// Arrange
HttpConfiguration config = new HttpConfiguration();
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Customer>(typeof(Customer).Name);
IEdmModel model = modelBuilder.GetEdmModel();
// Act
config.SetEdmModel(model);
IEdmModel newModel = config.GetEdmModel();
// Assert
Assert.Same(model, newModel);
}
示例4: ODataActionTests
public ODataActionTests()
{
_configuration = new HttpConfiguration();
_model = GetModel();
_formatter = new ODataMediaTypeFormatter(_model);
_configuration.Formatters.Clear();
_configuration.Formatters.Insert(0, _formatter);
_configuration.SetEdmModel(_model);
_configuration.Routes.MapHttpRoute("OData", "{*odataPath}", new { controller = "Customers", boundId = "1", id = "1" });
_configuration.Routes.MapHttpRoute(ODataRouteNames.GetById, "{controller}({id})");
_configuration.Routes.MapHttpRoute(ODataRouteNames.InvokeBoundAction, "{controller}({boundId})/{odataAction}");
_configuration.Routes.MapHttpRoute(ODataRouteNames.Metadata, "$metadata");
_server = new HttpServer(_configuration);
_client = new HttpClient(_server);
}
示例5: InitializeConfiguration
private static HttpConfiguration InitializeConfiguration(string controllerName, bool useCustomEdmModel)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("default", "{controller}/{id}", new { id = RouteParameter.Optional });
if (controllerName == "QueryCompositionCustomerGlobal")
{
config.Filters.Add(new QueryableAttribute());
}
if (useCustomEdmModel)
{
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<QueryCompositionCustomer>(typeof(QueryCompositionCustomer).Name);
IEdmModel model = modelBuilder.GetEdmModel();
config.SetEdmModel(model);
}
return config;
}
示例6: GetPostRequest
private HttpRequestMessage GetPostRequest(string url)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
HttpConfiguration config = new HttpConfiguration();
config.SetEdmModel(GetModel());
IHttpRoute route = new Mock<IHttpRoute>().Object;
IHttpRouteData routeData = new HttpRouteData(route);
routeData.Values["odataPath"] = GetODataPath(url);
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
return request;
}
示例7: GetPostRequest
private HttpRequestMessage GetPostRequest(string url)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
HttpConfiguration config = new HttpConfiguration();
IEdmModel model = GetModel();
config.SetEdmModel(model);
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
IHttpRoute route = new Mock<IHttpRoute>().Object;
request.Properties["MS_ODataPath"] = new DefaultODataPathHandler(model).Parse(GetODataPath(url));
return request;
}