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 ...
随机推荐
- hpp.h与.h的区别
hpp,其实质就是将.cpp的实现代码混入.h头文件当中,定义与实现都包含在同一文件,则该类的调用者只需要include该hpp文件即可,无需再将cpp加入到project中进行编译.而实现代码将直接 ...
- [转]order by 1是什么意思?
ORDER BY 1 表示 所select 的字段按第一个字段排序 ORDER BY ASC应该没有这样写法,ORDER BY 后面不是字段就是数字, 可以ORDER BY 1 ASC 或者ORDER ...
- python对文件进行读写操作
转:http://sucre.iteye.com/blog/704077 ython进行文件读写的函数是open或file file_handler = open(filename,,mode) Ta ...
- NodeJs——入门
关于NPM: npm 是 nodejs 的包管理和分发工具.它可以让 javascript 开发者能够更加轻松的共享代码和共用代码片段,并且通过 npm 管理你分享的代码也很方便快捷和简单. 一 No ...
- 大数据框架-Zookeeper
Hadoop的分布式协同服务,让分布式系统碰到失败时候,能够正确处理此类问题.基础功能:master选举,数据同步.Zooleeper集群有Client和Server(leader和follower) ...
- 一点一点看JDK源码(五)java.util.ArrayList 后篇之forEach
一点一点看JDK源码(五)java.util.ArrayList 后篇之forEach liuyuhang原创,未经允许禁止转载 本文举例使用的是JDK8的API 目录:一点一点看JDK源码(〇) 代 ...
- Web—05-常用css列表
color 设置文字的颜色,如: color:red; font-size 设置文字的大小,如:font-size:12px; font-family 设置文字的字体,如:font-family:'微 ...
- Swift _ OC _ 混编
Swift _ OC _ 混编 在OC环境下使用Swift. GitHub源码
- .Net core 还原Nuget包失败的解决方法
今天是2018最后一天了,真是神奇的一年啊,写个博客压压惊,来年继续加油吧..... 正文: 当我们打开.net core 项目时候,发现输出提示nuget包还原失败,这个时候首先要考虑.Net Co ...
- Redis服务端和客户端的命令
服务器端 服务器端的命令为redis-server 可以使⽤help查看帮助⽂档 redis-server --help 个人习惯 ps aux | grep redis 查看redis服务器进程su ...