예제 #1
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (_componentId != 0)
                {
                    var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
                    if (mgr != null)
                    {
                        mgr.FRevokeComponent(_componentId);
                    }
                    _componentId = 0;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }


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

            Log.Close();

            base.Dispose(disposing);
        }
예제 #2
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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            Log.Initialize();
            ProbeEnvironment.Initialize();
            TempManager.Init(TempDir);
            Snippets.SnippetDeploy.DeploySnippets();
            CodeModel.SignatureDocumentor.Initialize();

            ThreadHelper.ThrowIfNotOnUIThread();

            // Proffer the service.	http://msdn.microsoft.com/en-us/library/bb166498.aspx
            var langService = new ProbeLanguageService(this);

            langService.SetSite(this);
            (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true);

            // Register a timer to call our language service during idle periods.
            var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (_componentId == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out _componentId);
            }

            _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this);
            TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie);

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                Commands.InitCommands(mcs);
            }

            _functionScanner = new FunctionFileScanning.FFScanner();

            // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered.
            _dteEvents = Shell.DTE.Events;

            _dteDocumentEvents = _dteEvents.DocumentEvents;
            _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
        }
예제 #3
0
        public FFApp(FFScanner scanner, FFDatabase db, ProbeAppSettings appSettings)
        {
            _scanner     = scanner ?? throw new ArgumentNullException(nameof(scanner));
            _appSettings = appSettings ?? throw new ArgumentNullException(nameof(appSettings));

            if (!_appSettings.Initialized)
            {
                return;
            }

            var conn = db.Connection;

            if (conn == null)
            {
                return;
            }

            // Load app info
            using (var cmd = db.CreateCommand("select rowid from app where name = @name"))
            {
                cmd.Parameters.AddWithValue("@name", _appSettings.AppName);
                using (var rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                {
                    if (rdr.Read())
                    {
                        _id = rdr.GetInt64(0);
                    }
                }
            }

            if (_id != 0)
            {
                // Load files
                var loadedFiles = new List <FFFile>();
                using (var cmd = db.CreateCommand("select rowid, * from file_ where app_id = @app_id and visible != 0"))
                {
                    cmd.Parameters.AddWithValue("@app_id", _id);
                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            loadedFiles.Add(new FFFile(this, db, rdr));
                        }
                    }
                }

                foreach (var file in loadedFiles)
                {
                    file.Load(db);
                    _files[file.FileName.ToLower()] = file;
                }

                using (var cmd = db.CreateCommand("select file_name, modified from file_ where app_id = @app_id and visible = 0"))
                {
                    cmd.Parameters.AddWithValue("@app_id", _id);
                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            var fileName = rdr.GetString(0);
                            var modified = rdr.GetDateTime(1);
                            _invisibleFiles[fileName.ToLower()] = modified;
                        }
                    }
                }
            }
            else             // _id == 0
            {
                using (var cmd = db.CreateCommand("insert into app (name) values (@name); select last_insert_rowid();"))
                {
                    cmd.Parameters.AddWithValue("@name", _appSettings.AppName);
                    _id = Convert.ToInt64(cmd.ExecuteScalar());
                }

                var options = ProbeToolsPackage.Instance.EditorOptions;
                if (!options.DisableBackgroundScan)
                {
                    Shell.ShowNotificationAsync(Res.FFDatabaseCreationNotification, Res.FFDatabaseCreationCaption);
                }
            }
        }