zoukankan      html  css  js  c++  java
  • 【MAF】MAF插件框架简介

    引言
       Managed Add-In Framework是一个插件式框架。它有两大作用,一个是解耦,插件和宿主由7个管道组成,两边都有适配器Adapter管道,能最大程度地降低插件和宿主的耦合度;一个是物理隔离,可以有程序域隔离和进程隔离,插件崩溃了不会搞挂宿主。
    资料
        具体的介绍和用法两本书有比较详细的介绍,如下
        《C#高级编程(第七版)》 50章MAF
        《WPF编程宝典》 32章插件模型
    注意
         基本用法上面两个书都有,但是需要注意的是接口参数不能用枚举,不然会出错。
         还有的话,就是进程隔离的调用方式如下

                _addInProcess = new AddInProcess();
                _addInProcess.KeepAlive = true;
                _addInProcess.Start();
                _process = _addInProcess.ProcessId;
    
                string path = Environment.CurrentDirectory;
                AddInStore.Update(path);
                IList<AddInToken> printerTokens = AddInStore.FindAddIns(typeof(HostView.PrinterHostView), path);
                if (printerTokens.Count > 0)
                {
                    AddInToken token = printerTokens.FirstOrDefault(x => x.Name == "PrinterAddIn");
                    if (token != null)
                    {
                        PrinterAddIn = token.Activate<HostView.PrinterHostView>( AddInSecurityLevel.FullTrust);
                      
                    }
    
                }

          可以监控ProcessId是否存在,来判断插件是否奔溃了.
    小结
          MAF框架可以实现物理隔离,但相对来说结构变复杂了,如果不需要物理隔离,可以采用MEF框架。

  • 相关阅读:
    Qt5 webview加载本地网页
    pwiz, a model generator
    编译python3
    [转]Centos配置国内yum源
    ubuntu下apt-get update出现hash校验和错误
    《LINUX程序设计 第四版》 阅读笔记:(一)
    [转]https方式使用git保存密码的方式
    用python产生一个好的秘钥
    Ubuntu关闭图形界面
    Numpy中的矩阵计算
  • 原文地址:https://www.cnblogs.com/caizl/p/5422359.html
Copyright © 2011-2022 走看看