bool TryInitialize()
        {
            try
            {
                _dte = SiteManager.GetGlobalService<DTE>();
                _running = _dte != null;
            }
            catch
            {
                _running = false;
            }
            if (!_running) return false;
            // TODO:  seen in the wild, _dte.Solution is null (?), need to schedule and restart initialization for those scenarios.
            _solution = new DteSolution(_dte.Solution);
            _solution.ProjectChanged += HandleProjectChange;
            var environment = ServiceLocator.GetService<IEnvironment>();
            _packageManager = ServiceLocator.GetService<IPackageManager>();

            _assembliesChanged = new EventWaitHandle(false, EventResetMode.AutoReset, System.Diagnostics.Process.GetCurrentProcess().Id + ASSEMBLY_NOTIFY);
            _rootDirectory = environment.DescriptorFile.Parent;
            _projectRepository = environment.ProjectRepository;
            RegisterFileListener();
            RefreshProjects();
            _timer = new Timer(_ => RefreshProjects(), null, Timeout.Infinite, Timeout.Infinite);
            return true;
        }
示例#2
0
        public static string Initialize()
        {
            lock (LOCKER)
            {
                if (_called) return null;

                _called = true;

                var dte = SiteManager.GetGlobalService<DTE>();
                
                AddInInstaller.Install(Path.GetDirectoryName(typeof(SolutionAddInEnabler).Assembly.Location));

                var solution = new DteSolution(dte.Solution);
                solution.OpenWrapAddInEnabled = true;
                return "OpenWrap enabled.";
            }
        }