Exemplo n.º 1
0
        /// <summary>
        /// 启动列表中所有的插件
        /// </summary>
        /// <param name="bundles"></param>
        private void StartBundles(IBundle[] bundles)
        {
            IServiceReference reference    = context.GetServiceReference(typeof(IStartLevel).FullName);
            IStartLevel       startService = null;

            if (reference != null)
            {
                startService = context.GetService <IStartLevel>(reference);
            }
            try
            {
                foreach (AbstractBundle bundle in bundles)
                {
                    if (bundle == null)
                    {
                        break;
                    }
                    if (bundle.BundleData.Policy == ActivatorPolicy.Lazy)
                    {
                        StartBundle(bundle, BundleOptions.Transient);
                    }
                    else
                    {
                        // always set the startlevel incase it has changed (bug 111549)
                        // this is a no-op if the level is the same as previous launch.
                        if (bundle.StartLevel == 0 && startService != null)
                        {
                            startService.SetBundleStartLevel(bundle, GetStartLevel());
                        }
                        StartBundle(bundle, BundleOptions.General);
                    }
                }
            }
            finally
            {
                if (reference != null)
                {
                    context.UngetService(reference);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 停止Word应程序管理器
 /// </summary>
 public void Stop()
 {
     if (_isActive)
     {
         if (_customTaskPaneReference != null)
         {
             _context.UngetService(_customTaskPaneReference);
         }
         if (_customTaskPanes != null)
         {
             _customTaskPanes.Dispose(); //释放对象
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 停止Word应程序管理器
 /// </summary>
 public void Stop()
 {
     if (isActive)
     {
         if (wordApplicationReference != null)
         {
             context.UngetService(wordApplicationReference);
         }
         var app = this.Application;
         if (app != null)
         {
             app.DocumentOpen        -= OnDocumentOpen;
             app.DocumentChange      -= OnDocumentChange;
             app.DocumentBeforeSave  -= OnDocumentBeforeSave;
             app.DocumentBeforeClose -= OnDocumentBeforeClose;
             object unKnown = Type.Missing;
             app.Quit(ref unKnown, ref unKnown, ref unKnown);
         }
     }
 }