/// <summary>
        /// 激活插件。
        /// </summary>
        public void Active()
        {
            if (IsActived)
            {
                return;
            }
            IAddin addin = AddinManager.LoadAddin(_info);

            if (addin != null)
            {
                Addin = addin;
                WpfAddinProxy proxy = addin as WpfAddinProxy;
                if (proxy != null)
                {
                    proxy.Transceiver = new InternalMessageTransceiver(proxy);
                }
            }
            if (addin != null)
            {
                IsActived = true;
                OnActived();
            }
            else
            {
                IsActived = false;
            }
        }
        public static void SendInternalMessage(this IAddin sender, InternalMessage message)
        {
            if (AppDomain.CurrentDomain.IsDefaultAppDomain())
            {
                return;
            }
            WpfAddinProxy proxy = AppDomain.CurrentDomain.GetData("proxy") as WpfAddinProxy;

            proxy?.OnSendInternalMessage(message);
        }
        /// <summary>
        /// 将插件加载到独立的应用程序域中。
        /// </summary>
        /// <param name="addinType">实现了 IAddin 接口的类型。</param>
        /// <param name="info">插件配置信息。</param>
        /// <returns>派生自 AddinProxy 类的实例。</returns>
        protected override IAddin LoadOnIsolatedAppDomain(Type addinType, AddinInfo info)
        {
            AddinProxy proxy = base.LoadOnIsolatedAppDomain(addinType, info) as AddinProxy;

            if (proxy != null)
            {
                WpfAddinProxy wpfProxy = proxy as WpfAddinProxy;
                if (wpfProxy != null)
                {
                    wpfProxy.Directory = Path.GetDirectoryName(addinType.Assembly.Location);
                }
            }
            return(proxy);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 初始化类型 Tumbler.Addin.Wpf.InternalMessageListner 实例。
 /// </summary>
 /// <param name="proxy">插件代理。</param>
 public InternalMessageTransceiver(WpfAddinProxy proxy)
 {
     Proxy = proxy;
 }