本文整理汇总了C#中IMapper.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# IMapper.Connect方法的具体用法?C# IMapper.Connect怎么用?C# IMapper.Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMapper
的用法示例。
在下文中一共展示了IMapper.Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map
public override void Map(IMapper map)
{
// register the route debugger
map.DebugRoute("routedebug");
// register the root of the site
map.Root<HomeController>(x => x.Index());
map.Resource<QuickStartController>(quickstart => quickstart.Only("show"));
// Connecting RouteSets: notice that we are connecting another RouteSet to this one
map.Connect<OtherRouteSet>();
// Mapping an area: notice, all these controllers are part of the area
map.Area<AreasController>("mappings", area =>
{
area.Resource<ResourceController>();
area.Resources<ResourcesController>(resources =>
{
// we are nesting a resource inside of another resource
resources.Resources<OtherResourcesController>(other => other.Only("index"));
// using collection
resources.Collection(r => r.Get("many"));
// using member
resources.Member(r => r.Get("lonely"));
});
area.Resource<AreasController>();
area.Resource<ExtrasController>(extras =>
{
// renaming the url part
extras.As("extras");
// using member, notice collection is unavailable
extras.Member(e => e.Get("member"));
// Use path
extras.Path("using_path").To<ExtrasController>(e => e.UsingPath()).GetOnly();
// Using route
extras.Route(new Route("mappings/extras/with_route", new RouteValueDictionary(new { controller = "extras", action = "usingroute", area = "mappings" }), new MvcRouteHandler()));
// Format route action, register like always
extras.Member(e => e.Get("awesome"));
// enable format routes
extras.WithFormatRoutes();
});
});
// Not the route debuger, just a controller
map.Resource<RouteDebuggerController>(debug => debug.Only("show"));
// redirects should always be last
map.Connect<RedirectRouteSet>();
}
示例2: Map
public override void Map(IMapper map)
{
// Additional delete mapping.
MapDelete = true;
map.DebugRoute("routedebug");
// Mapped the index
map.Root<HomeController>(x => x.Index());
// Mapping the resource, but I only want an index.
// map.Resource<ProductsController>(p => { p.Only("index"); p.As("products"); }); // ERROR and no index in the RouteDebug...
// Mapping the resource, just give me everything.
map.Resources<ProductsController>(p => p.As("products")); // NO ERROR, But also no index in the RouteDebug...
// Created a seperate set.
map.Connect<AdminRouteSet>();
}
示例3: Map
public override void Map(IMapper map)
{
map.Path("test").To<PostsController>(x => x.Index());
map.Connect<AnotherRouteSet>("api", new[] { typeof(PostsController).Namespace });
}