Пример #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Command.Initialize(this);
            base.Initialize();

            OpenFileManager.CreateInstance(this);

            var    extensionUtility         = new ExtensionUtility(typeof(CommandPackage));
            string extensionPath            = extensionUtility.GetExtensionPath();
            var    everythingProcessManager = new EverythingProcessManager(extensionPath);

            bool serviceIsStartedNow = false;

            if (!everythingProcessManager.IsServiceInstalled())
            {
                everythingProcessManager.InstallService();
                serviceIsStartedNow = true;
            }
            else if (!everythingProcessManager.IsServiceRunning())
            {
                everythingProcessManager.StartService();
                serviceIsStartedNow = true;
            }
            // if only service is running
            if (everythingProcessManager.GetNumberOfEverythingProcess() <= 1)
            {
                if (serviceIsStartedNow)
                {
                    // wait untill service will be fine
                    System.Threading.Thread.Sleep(3000);
                }
                everythingProcessManager.StartClientInBackgroundMode();
            }

            var everythingManager = new EverythingManager();

            everythingManager.Init(extensionPath);
            EverythingSearchTask.CommandPackage = this;
        }