コード例 #1
0
        public void Initialize()
        {
            _uiTaskScheduler = TTasks.TaskScheduler.FromCurrentSynchronizationContext();
            _taskProvider    = new VulnerabilityTaskProvider(this._serviceProvider);
            _markerProvider  = new PackageReferenceMarkerProvider(_taskProvider);
            _refreshTimer    = new Timer(new TimerCallback(RefreshTimer), null, Timeout.Infinite, Timeout.Infinite);

            _selectionEvents = new EventSinks.VsSelectionEvents(VSPackage.Instance.MonitorSelection);
            _selectionEvents.SolutionOpened += SelectionEvents_SolutionOpened;

            _packageInstallerEvents = ServiceLocator.GetInstance <IVsPackageInstallerEvents>();

            if (_packageInstallerEvents == null)
            {
                throw new InvalidOperationException(string.Format(Resources.Culture, Resources.General_MissingService, typeof(IVsPackageInstallerEvents).FullName));
            }

            _packageInstallerEvents.PackageInstalled        += InstallerEvents_PackageInstalled;
            _packageInstallerEvents.PackageUninstalled      += InstallerEvents_PackageUninstalled;
            _packageInstallerEvents.PackageReferenceAdded   += InstallerEvents_PackageReferenceAdded;
            _packageInstallerEvents.PackageReferenceRemoved += InstallerEvents_PackageReferenceRemoved;

            _dte = ServiceLocator.GetInstance <DTE>();

            if (_dte == null)
            {
                throw new InvalidOperationException(string.Format(Resources.Culture, Resources.General_MissingService, typeof(DTE).FullName));
            }

            _documentEvents = _dte.Events.DocumentEvents;

            _documentEvents.DocumentOpened  += OnDocumentOpened;
            _documentEvents.DocumentClosing += OnDocumentClosing;
        }
コード例 #2
0
        public void Initialize()
        {
            _uiTaskScheduler = TTasks.TaskScheduler.FromCurrentSynchronizationContext();
            _taskProvider = new VulnerabilityTaskProvider(this._serviceProvider);
            _markerProvider = new PackageReferenceMarkerProvider(_taskProvider);

            _selectionEvents = new EventSinks.VsSelectionEvents(VSPackage.Instance.MonitorSelection);
            _selectionEvents.SolutionOpened += SelectionEvents_SolutionOpened;

            _packageInstallerEvents = ServiceLocator.GetInstance<IVsPackageInstallerEvents>();

            if (_packageInstallerEvents == null)
            {
                throw new InvalidOperationException(string.Format(Resources.Culture, Resources.General_MissingService, typeof(IVsPackageInstallerEvents).FullName));
            }
            
            _packageInstallerEvents.PackageReferenceAdded += InstallerEvents_PackageReferenceAdded;
            _packageInstallerEvents.PackageReferenceRemoved += InstallerEvents_PackageReferenceRemoved;

            _dte = ServiceLocator.GetInstance<DTE>();

            if (_dte == null)
            {
                throw new InvalidOperationException(string.Format(Resources.Culture, Resources.General_MissingService, typeof(DTE).FullName));
            }

            _documentEvents = _dte.Events.DocumentEvents;

            _documentEvents.DocumentOpened += OnDocumentOpened;
            _documentEvents.DocumentClosing += OnDocumentClosing;
        }
コード例 #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _refreshTimer?.Dispose();
                    _markerProvider?.Dispose();

                    if (_packageInstallerEvents != null)
                    {
                        _packageInstallerEvents.PackageReferenceAdded   -= InstallerEvents_PackageReferenceAdded;
                        _packageInstallerEvents.PackageReferenceRemoved -= InstallerEvents_PackageReferenceRemoved;
                        _packageInstallerEvents.PackageInstalled        -= InstallerEvents_PackageInstalled;
                        _packageInstallerEvents.PackageUninstalled      -= InstallerEvents_PackageUninstalled;
                    }

                    if (_documentEvents != null)
                    {
                        _documentEvents.DocumentOpened  -= OnDocumentOpened;
                        _documentEvents.DocumentClosing -= OnDocumentClosing;
                    }

                    if (_selectionEvents != null)
                    {
                        _selectionEvents.SolutionOpened -= SelectionEvents_SolutionOpened;
                        _selectionEvents.Dispose();
                    }

                    _taskProvider?.Dispose();
                    _backgroundQueue?.Dispose();

                    _auditResults.Clear();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                //_packageReferenceMarkerClients = null;
                _markerProvider         = null;
                _packageInstallerEvents = null;
                _documentEvents         = null;
                _selectionEvents        = null;
                _dte             = null;
                _taskProvider    = null;
                _backgroundQueue = null;
                _auditResults    = null;

                disposedValue = true;
            }
        }
コード例 #4
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (_markerProvider != null)
                    {
                        _markerProvider.Dispose();
                    }

                    if (_packageInstallerEvents != null)
                    {
                        _packageInstallerEvents.PackageReferenceAdded -= InstallerEvents_PackageReferenceAdded;
                        _packageInstallerEvents.PackageReferenceRemoved -= InstallerEvents_PackageReferenceRemoved;
                    }

                    if (_documentEvents != null)
                    {
                        _documentEvents.DocumentOpened -= OnDocumentOpened;
                        _documentEvents.DocumentClosing -= OnDocumentClosing;
                    }

                    if (_selectionEvents != null)
                    {
                        _selectionEvents.SolutionOpened -= SelectionEvents_SolutionOpened;
                        _selectionEvents.Dispose();
                    }

                    if (_taskProvider != null)
                    {
                        _taskProvider.Dispose();
                    }

                    if (_backgroundQueue != null)
                    {
                        _backgroundQueue.Dispose();
                    }

                    _auditResults.Clear();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                //_packageReferenceMarkerClients = null;
                _markerProvider = null;
                _packageInstallerEvents = null;
                _documentEvents = null;
                _selectionEvents = null;
                _dte = null;
                _taskProvider = null;
                _backgroundQueue = null;
                _auditResults = null;

                disposedValue = true;
            }
        }