使用TypeMappingConfiguration类

 //Override the default subnamespaces
var config = new TypeMappingConfiguration
{
DefaultSubNamespaceForViewModels = "MyViewModels",
DefaultSubNamespaceForViews = "MyViews"
}; ViewLocator.ConfigureTypeMappings(config);
ViewModelLocator.ConfigureTypeMappings(config); //Resolves:
//MyProject.MyViewModels.CustomerViewModel -> MyProject.MyViews.CustomerView
//MyProject.MyViewModels.CustomerPageViewModel -> MyProject.MyViews.CustomerPage
//MyProject.MyViews.CustomerView -> MyProject.MyViewModels.CustomerViewModel
//MyProject.MyViews.CustomerPage -> MyProject.MyViewModels.CustomerPageViewModel //Change ViewModel naming convention to always exclude View suffix
var config = new TypeMappingConfiguration
{
DefaultSubNamespaceForViewModels = "MyViewModels",
DefaultSubNamespaceForViews = "MyViews",
IncludeViewSuffixInViewModelNames = false
}; ViewLocator.ConfigureTypeMappings(config);
ViewModelLocator.ConfigureTypeMappings(config); //Resolves:
//MyProject.MyViewModels.CustomerViewModel -> MyProject.MyViews.CustomerPage, MyProject.MyViews.CustomerView
//MyProject.MyViews.CustomerView -> MyProject.MyViewModels.CustomerViewModel
//MyProject.MyViews.CustomerPage -> MyProject.MyViewModels.CustomerViewModel //Change naming conventions to place name suffixes before the base name (i.e. name prefix)
var config = new TypeMappingConfiguration
{
NameFormat = "{1}{0}",
IncludeViewSuffixInViewModelNames = false
}; ViewLocator.ConfigureTypeMappings(config);
ViewModelLocator.ConfigureTypeMappings(config); //Resolves:
//MyProject.ViewModels.ViewModelCustomer -> MyProject.Views.PageCustomer, MyProject.Views.ViewCustomer
//MyProject.Views.ViewCustomer -> MyProject.ViewModels.ViewModelCustomer
//MyProject.Views.PageCustomer -> MyProject.ViewModels.ViewModelCustomer //Change naming conventions to omit name suffixes altogether (i.e. distinguish View and ViewModel types by namespace alone)
var config = new TypeMappingConfiguration
{
UseNameSuffixesInMappings = false
}; ViewLocator.ConfigureTypeMappings(config);
ViewModelLocator.ConfigureTypeMappings(config); //Resolves:
//MyProject.ViewModels.Customer -> MyProject.Views.Customer
//MyProject.Views.Customer -> MyProject.ViewModels.Customer //Configure for Spanish language and semantics
var config = new TypeMappingConfiguration()
{
DefaultSubNamespaceForViewModels = "ModelosDeVistas",
DefaultSubNamespaceForViews = "Vistas",
ViewModelSuffix = "ModeloDeVista",
ViewSuffixList = new List<string>(new string[] { "Vista", "Pagina" }),
NameFormat = "{1}{0}",
IncludeViewSuffixInViewModelNames = false
}; ViewLocator.ConfigureTypeMappings(config);
ViewModelLocator.ConfigureTypeMappings(config); //Resolves:
//MiProyecto.ModelosDeVistas.ModeloDeVistaCliente -> MiProyecto.Vistas.VistaCliente, MiProyecto.Vistas.PaginaCliente
//MiProyecto.Vistas.VistaCliente -> MiProyecto.ModelosDeVistas.ModeloDeVistaCliente
//MiProyecto.Vistas.PaginaCliente -> MiProyecto.ModelosDeVistas.ModeloDeVistaCliente

最新文章

  1. 新技术≠颠覆:CIO 要有战略耐心
  2. centos6.5下安装qq2012
  3. C#正则表达式Regex类的用法
  4. C++函数指针
  5. 编译nginx的源码安装subs_filter模块
  6. WatiN和HttpWatch交互简介
  7. nginx 支持pathinfo的配置文件
  8. HDU 4627 E(Contest #3)
  9. 滑雪 (搜索)(dp)(贪心)
  10. ios消息的交互方式
  11. k8s 集群基本概念
  12. 一张图讲解对象锁和关键字synchronized修饰方法
  13. python_10_文件操作
  14. IOS空数据页面,网络加载失败以及重新登陆View的封装(不需要继承)
  15. js 禁止f12、Ctrl +S 、右键
  16. 【EMV L2】终端风险管理(Terminal Risk Management)
  17. ELK安装(windows)
  18. WordPress UpdraftPlus插件 Google Drive 备份
  19. Bytom 移动端钱包SDK FAQ
  20. JDBC事务,银行转账,货物进出库等等。

热门文章

  1. 用Mochiweb打造百万级Comet应用,第一部分
  2. sql server中查询结果集顺序问题
  3. 【t096】树的序号
  4. Groovy&amp;Gradle总结
  5. Compile Graphics Magick, Boost, Botan and QT with MinGW64 under Windows 7 64
  6. Oracle停止一个JOB
  7. Java8初体验(二)Stream语法详解---符合人的思维模式,数据源--》stream--&gt;干什么事(具体怎么做,就交给Stream)--》聚合
  8. jQuery memory&amp;unique&amp;stopOnfalse
  9. WPF窗口继承实现统一风格的自定义窗口
  10. c语言学习笔记(12)——补码