Caliburn.Micro 自定义View和ViewModel的匹配规则
2024-08-25 00:48:45
使用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
最新文章
- 新技术≠颠覆:CIO 要有战略耐心
- centos6.5下安装qq2012
- C#正则表达式Regex类的用法
- C++函数指针
- 编译nginx的源码安装subs_filter模块
- WatiN和HttpWatch交互简介
- nginx 支持pathinfo的配置文件
- HDU 4627 E(Contest #3)
- 滑雪 (搜索)(dp)(贪心)
- ios消息的交互方式
- k8s 集群基本概念
- 一张图讲解对象锁和关键字synchronized修饰方法
- python_10_文件操作
- IOS空数据页面,网络加载失败以及重新登陆View的封装(不需要继承)
- js 禁止f12、Ctrl +S 、右键
- 【EMV L2】终端风险管理(Terminal Risk Management)
- ELK安装(windows)
- WordPress UpdraftPlus插件 Google Drive 备份
- Bytom 移动端钱包SDK FAQ
- JDBC事务,银行转账,货物进出库等等。
热门文章
- 用Mochiweb打造百万级Comet应用,第一部分
- sql server中查询结果集顺序问题
- 【t096】树的序号
- Groovy&;Gradle总结
- Compile Graphics Magick, Boost, Botan and QT with MinGW64 under Windows 7 64
- Oracle停止一个JOB
- Java8初体验(二)Stream语法详解---符合人的思维模式,数据源--》stream-->;干什么事(具体怎么做,就交给Stream)--》聚合
- jQuery memory&;unique&;stopOnfalse
- WPF窗口继承实现统一风格的自定义窗口
- c语言学习笔记(12)——补码