Prism MEF example
Related Attributes
These attributes are under namespace System.ComponentModel.Composition
- Import
The attribute can be used on fields, properties, parameters. E.g. If a property is defined with the attribute, the property will be created automatically when the object is created.
Example:
[Import(RequiredCreationPolicy = CreationPolicy.NonShared)]
public EmployeeGridViewModel Model
{
get
{
return this.Owner.DataContext as EmployeeGridViewModel;
}
set
{
this.Owner.DataContext = value;
}
}
- ImportingConstructor
For previous example, how to create an instance of EmployeeGridViewModel? It will need attribute ImportingConstructor.
[ImportingConstructor]
public EmployeeGridViewModel(IEmployeeService employeeService)
{
this.employeeService = employeeService;
...
}
- Export: This attribute is used to register a class into MEF.
Next question is how to create an instance of IEmployeeService, look this:
[Export(typeof(IEmployeeService))]
[PartCreationPolicy(CreationPolicy.Shared)]
public class EmployeeService : IEmployeeService
{
}
These code registers EmployeeService as an impelement of type IEmployeeService.
- PartCreationPolicy
The attribtue is used with attribute Export, tell MEF the class creation policy, implment a singleton policy or create an instance always.
Prism MEF example的更多相关文章
- Prism&MEF构建开发框架 (一)
Shell框架XECA shell.xaml主要起到是一个容器或壳的作用 <Window x:Class="XECA.Shell" xmlns="http ...
- Prism&MEF构建开发框架 (三)
菜单管控模块EntityFW 菜单的加载采用MEF技术,程序实现思路: 1 .主菜单加载页面MainMenuView.xaml指向MenuRegion 2. 菜单Item点击及内容加载,采用订阅模式, ...
- 一步步实现 Prism + MEF(一)--- 搭建框架
第一步:构建一个名为Bootstrapper的类作为引导程序. class Bootstrapper : MefBootstrapper { } 第二步:在MainWindow窗体中添加一个Coont ...
- 一步步实现 Prism + MEF(二)--- 绑定命令
Prism程序集为我们提供了DelegateCommand命令,使用该命令可实现窗口直接绑定.第一步:在ViewModel中定义一个DelegateCommand属性. public Delegate ...
- Prism&MEF构建开发框架
系统框架构想效果图 平台简单由左侧菜单和右侧内容区以及顶部系统和用户信息区构成 菜单根据系统模块动态加载 右侧,根据左侧选中菜单动态加载子模块,子模块集合以tab选项卡方式布局 系统模块划分为Shel ...
- 【翻译】WPF应用程序模块化开发快速入门(使用Prism+MEF)
编译并运行快速入门 需要在VisualStudio 2010上运行此快速入门示例 代码下载:ModularityWithMef.zip 先重新生成解决方案 再按F5运行此示例 说明: 在此快速入门示例 ...
- Prism for WPF初探(构建简单的模块化开发框架)
先简单的介绍一下Prism框架,引用微软官方的解释: Prism provides guidance to help you more easily design and build, flexibl ...
- Prism6下的MEF:基于微软企业库的Cache
通常,应用程序可以将那些频繁访问的数据,以及那些需要大量处理时间来创建的数据存储在内存中,从而提高性能.基于微软的企业库,我们的快速创建一个缓存的实现. 新建PrismSample.Infrastru ...
- Prism for WPF
Prism for WPF Prism for WPF初探(构建简单的模块化开发框架) 先简单的介绍一下Prism框架,引用微软官方的解释: Prism provides guidance to ...
随机推荐
- PHP-----JSOM类型数据
JS里的数据类型 JS里的一种数据类型,JSOM类型数据 JSOM这种数据类型,在使用JS和jquery时经常使用的到,比较重要.用起来比较简单. <title>无标题文档</tit ...
- 2018 Multi-University Training Contest 4 Problem B. Harvest of Apples 【莫队+排列组合+逆元预处理技巧】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6333 Problem B. Harvest of Apples Time Limit: 4000/200 ...
- 将数组打印到txt文件中
用print_r 将数组打印到txt文件中. 1.function save_log($content='', $file='app') { $logDir = './logs'; $now ...
- 关于Git提交规范
自古至今,无规矩不成方圆. Git提交也有其规范,业内做的比较好的,比较具有参考价值的就是Angular的提交. Angular提交规范: <type>(<scope>): & ...
- 挖矿病毒——test用户的ld-linux-x86-64任务
表现:24核48线程的机器,极度占用系统CPU资源(约60%) 通过top查看之后可以看到排在首位的是test用户的ld-linux-x86-64任务. solution: 首先,/etc/passw ...
- java soa接口测试,可以使用http协议调用
post调用url:“接口url”+/rpc post调用参数body: { "ver": "接口版本号", "soa":{"re ...
- 火狐中jq的attr出现的bug问题用prop代替
再工作的时候遇到一个很奇怪的问题 ,就是attr属性不好使!就问度娘去了...... 结果如下: .prop() 1..prop( propertyName ) 获取匹配集合中第一个元素的Prop ...
- ASP.NET CORE MVC 2.0 如何在Filter中使用依赖注入来读取AppSettings,及.NET Core控制台项目中读取AppSettings
问: ASP.NET CORE MVC 如何在Filter中使用依赖注入来读取AppSettings 答: Dependency injection is possible in filters as ...
- Python 多客户端
服务端代码 #引入socketserver模块 import socketserver #定义处理类必须继承BaseRequestHandler类 class my_server(socketserv ...
- 基于java的简易计算器实现
方法: 1.将string类型的表达式输入转换成后缀表达式 2.计算后缀表达式 步骤一:将string类型的表达式输入转换成后缀表达式 输入字符串表达式,并将表达式转换成char型数组 String ...