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的更多相关文章

  1. Prism&MEF构建开发框架 (一)

    Shell框架XECA shell.xaml主要起到是一个容器或壳的作用 <Window x:Class="XECA.Shell"      xmlns="http ...

  2. Prism&MEF构建开发框架 (三)

    菜单管控模块EntityFW 菜单的加载采用MEF技术,程序实现思路: 1 .主菜单加载页面MainMenuView.xaml指向MenuRegion 2. 菜单Item点击及内容加载,采用订阅模式, ...

  3. 一步步实现 Prism + MEF(一)--- 搭建框架

    第一步:构建一个名为Bootstrapper的类作为引导程序. class Bootstrapper : MefBootstrapper { } 第二步:在MainWindow窗体中添加一个Coont ...

  4. 一步步实现 Prism + MEF(二)--- 绑定命令

    Prism程序集为我们提供了DelegateCommand命令,使用该命令可实现窗口直接绑定.第一步:在ViewModel中定义一个DelegateCommand属性. public Delegate ...

  5. Prism&MEF构建开发框架

    系统框架构想效果图 平台简单由左侧菜单和右侧内容区以及顶部系统和用户信息区构成 菜单根据系统模块动态加载 右侧,根据左侧选中菜单动态加载子模块,子模块集合以tab选项卡方式布局 系统模块划分为Shel ...

  6. 【翻译】WPF应用程序模块化开发快速入门(使用Prism+MEF)

    编译并运行快速入门 需要在VisualStudio 2010上运行此快速入门示例 代码下载:ModularityWithMef.zip 先重新生成解决方案 再按F5运行此示例 说明: 在此快速入门示例 ...

  7. Prism for WPF初探(构建简单的模块化开发框架)

    先简单的介绍一下Prism框架,引用微软官方的解释: Prism provides guidance to help you more easily design and build, flexibl ...

  8. Prism6下的MEF:基于微软企业库的Cache

    通常,应用程序可以将那些频繁访问的数据,以及那些需要大量处理时间来创建的数据存储在内存中,从而提高性能.基于微软的企业库,我们的快速创建一个缓存的实现. 新建PrismSample.Infrastru ...

  9. Prism for WPF

    Prism for WPF Prism for WPF初探(构建简单的模块化开发框架)   先简单的介绍一下Prism框架,引用微软官方的解释: Prism provides guidance to ...

随机推荐

  1. idea中ssm自动配置

    自动生成 只需要创建好maven项目,然后创建一个类Test,复制代码粘贴即可 使用注意: 代码 import java.io.*; public class Test { //包名格式 //列如配置 ...

  2. Spring mvc实现ex导入导出

    依赖架包 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</arti ...

  3. nodejs 做的带管理后台的东东,主要学习到 ....我忘了学到什么了

    效果 http://www.steel-pot.com/ function handleStr(str,isHtml,callback) { if(!isHtml) { callback(str); ...

  4. SimpleProfile_GetParameter && SimpleProfile_SetParameter

    /********************************************************************* * @fn SimpleProfile_GetParame ...

  5. 【前端框架-Vue-基础】$attr及$listeners实现跨多级组件的通信

    父子 A 组件与 B 组件之间的通信: (父子组件) 如上图所示,A.B.C三个组件依次嵌套,按照 Vue 的开发习惯,父子组件通信可以通过以下方式实现: A to B 通过props的方式向子组件传 ...

  6. ConfigurationManager.AppSettings方法

    一 配置文件概述: 应用程序配置文件是标准的 XML 文件,XML 标记和属性是区分大小写的.它是可以按需要更改的,开发人员可以使用配置文件来更改设置,而不必重编译应用程序.配置文件的根节点是conf ...

  7. 鸟哥私房菜笔记-1 (S0_S3)

    学新东西,总感觉还是看书来的实在,直接看教程上手太慢且没有目的, 接下来先啃鸟哥这本吧,买的第三版,内容在鸟哥站上都有: 鸟哥的 Linux 私房菜 -- 基础学习篇目录 (繁体) http://cn ...

  8. jquery头像上传剪裁插件cropper的前后台demo

    因为一个项目要做一个头像上传的功能,因此选择了使用jquery的头像插件cropper,cropper是一款使用简单且功能强大的图片剪裁jQuery插件,但是在使用的时候,有一个很大的坑需要注意,那就 ...

  9. $.extend() 合并问题

  10. Eclipse中html/js/jsp代码的自动联想

    1.打开eclipse→Windows→Preferences→Java→Editor→Content Assist 修改Auto Activation triggers for java的值为:.a ...