コード例 #1
0
        /// <summary>
        /// 获取插件的激活器。
        /// </summary>
        /// <param name="addinInfo">插件信息。</param>
        /// <returns>插件激活器。</returns>
        public AddinActivatorBase GetAddinActivator(WpfAddinInfo addinInfo)
        {
            Type activatorType = ParseType(addinInfo.ActivatorType, addinInfo.Directory);

            if (activatorType == null || activatorType.BaseType.AssemblyQualifiedName != typeof(AddinActivatorBase).AssemblyQualifiedName)
            {
                return(null);
            }
            try
            {
                Assembly           assembly  = AppDomain.CurrentDomain.Load(activatorType.Assembly.FullName);
                AddinActivatorBase activator = (AddinActivatorBase)assembly.CreateInstance(activatorType.FullName);
#if DEBUG
                if (activator != null)
                {
                    Console.WriteLine($"Created activator {activatorType.Assembly.FullName}");
                }
#endif
                return(activator);
            }
            catch (MissingMemberException ex)
            {
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取插件的激活器。
        /// </summary>
        /// <param name="info">插件信息。</param>
        /// <returns>插件激活器。</returns>
        public AddinActivatorBase GetAddinActivator(WpfAddinInfo info)
        {
            String privateBinPath = $"addins/{System.IO.Path.GetDirectoryName(info.Location)}";

            AddPrivateBinPath(privateBinPath);
            AddinActivatorBase activator = _loader.GetAddinActivator(info);

            if (activator != null)
            {
                activator._info         = info;
                activator._addinManager = this;
            }
            return(activator);
        }