Пример #1
0
        public virtual void OnWorkspaceCleared(WorkspaceModel workspace)
        {
            if (WorkspaceCleared != null)
            {
                WorkspaceCleared(workspace);
            }

            WorkspaceEvents.OnWorkspaceCleared();
        }
Пример #2
0
        public virtual void OnWorkspaceClearing()
        {
            if (WorkspaceClearing != null)
            {
                WorkspaceClearing();
            }

            WorkspaceEvents.OnWorkspaceClearing();
        }
Пример #3
0
        protected virtual void OnWorkspaceAdded(WorkspaceModel obj)
        {
            var handler = WorkspaceAdded;

            if (handler != null)
            {
                handler(obj);
            }

            WorkspaceEvents.OnWorkspaceAdded(obj.Guid, obj.Name, obj.GetType());
        }
Пример #4
0
        protected virtual void OnWorkspaceRemoved(WorkspaceModel obj)
        {
            var handler = WorkspaceRemoved;

            if (handler != null)
            {
                handler(obj);
            }

            WorkspaceEvents.OnWorkspaceRemoved(obj.Guid, obj.Name);
        }
Пример #5
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            NLogConfigurationService.ConfigureNLog();
            NLogConfigurationService.ConfigureMiniProfilerWithDefaultLogger();

            Logger logger = LogManager.GetLogger("error");

            logger.Info("Extension initalizing");

            EnvDTE = await GetServiceAsync(typeof(DTE)) as DTE2;

            Assumes.Present(EnvDTE);

            DteSemaphore.Release();

            Storage = new PackageStorage();

            var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel;

            Assumes.Present(componentModel);

            //Initialize public components, initialize instances that are dependent on any component
            TextManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager;

            EditorAdaptersFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>();

            DocumentNavigationInstance.InjectDTE(EnvDTE);
            //Prepare package events
            var indexingQueue   = new ProjectIndexingQueue();
            var workspaceEvents = new WorkspaceEvents(indexingQueue);

            Workspace = componentModel.GetService <VisualStudioWorkspace>();
            Workspace.WorkspaceChanged += (s, e) => ThreadHelper.JoinableTaskFactory.RunAsync(async() => await workspaceEvents.WorkspaceChangedAsync(s, e));

            var indexingWorkflow = new IndexingWorkflow(Storage.IndexingWorkflowOptions, new ProjectItemRetreiver(EnvDTE), Storage);

            _envDteEvents = EnvDTE.Events as Events2;
            if (_envDteEvents != null)
            {
                ProjectItemEventsActions projectItemEvents = new ProjectItemEventsActions();
                _envDteProjectItemsEvents              = _envDteEvents.ProjectItemsEvents;
                _envDteProjectItemsEvents.ItemAdded   += projectItemEvents.ItemAdded;
                _envDteProjectItemsEvents.ItemRemoved += projectItemEvents.ItemRemoved;
                _envDteProjectItemsEvents.ItemRenamed += projectItemEvents.ItemRenamed;

                EventHandlers.BuildEventsActions buildEvents = new EventHandlers.BuildEventsActions();
                _buildEvents = _envDteEvents.BuildEvents;
                _buildEvents.OnBuildBegin += buildEvents.OnBuildBegin;
            }

            var solutionEventsActions = new VSSolutionEventsActions(indexingWorkflow);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            await ResultWindowCommand.InitializeAsync(this);

            OutputWindowLogger.Init(await GetServiceAsync(typeof(SVsOutputWindow)) as SVsOutputWindow);
            IStatusBar = await GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;

            var svsSolution = await GetServiceAsync(typeof(SVsSolution));

            Solution = svsSolution as IVsSolution;
            Assumes.Present(Solution);

            await HandleSolutionAsync(svsSolution, solutionEventsActions, indexingQueue);


            _solutionEventsHandler = new SolutionEventsHandler(solutionEventsActions);
            Solution.AdviseSolutionEvents(_solutionEventsHandler, out _solutionEventsCookie);

            await Goto.InitializeAsync(this);

            await RenameModalWindowCommand.InitializeAsync(this);

            await RenameCommand.InitializeAsync(this);

            await PrettyPrintCommand.InitializeAsync(this);
        }
Пример #6
0
 /// <summary>
 /// Triggers WorkspaceClearing event
 /// </summary>
 /// <param name="workspace">Workspace about to be cleared</param>
 public virtual void OnWorkspaceClearingStarted(WorkspaceModel workspace)
 {
     WorkspaceClearingStarted?.Invoke(workspace);
     WorkspaceEvents.OnWorkspaceClearing();
 }