/// <summary> /// Initializes the package right after it's been "sited" into the fully-initialized Visual Studio IDE. /// </summary> protected override void Initialize() { Logging.WriteLine("Initializing UnrealVS extension..."); // Grab the MenuCommandService MenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; // Get access to Visual Studio's DTE object. This object has various hooks into the Visual Studio // shell that are useful for writing extensions. DTE = (DTE)GetGlobalService(typeof(DTE)); Logging.WriteLine("DTE version " + DTE.Version); // Get selection manager and register to receive events SelectionManager = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection; SelectionManager.AdviseSelectionEvents(this, out SelectionEventsHandle); // Get solution and register to receive events SolutionManager = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2; UpdateUnrealLoadedStatus(); SolutionManager.AdviseSolutionEvents(this, out SolutionEventsHandle); // Grab the solution build manager. We need this in order to change certain things about the Visual // Studio environment, like what the active startup project is // Get solution build manager SolutionBuildManager = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; SolutionBuildManager.AdviseUpdateSolutionEvents(this, out UpdateSolutionEventsHandle); // Create our command-line editor CommandLineEditor = new CommandLineEditor(); // Create our startup project selector StartupProjectSelector = new StartupProjectSelector(); // Create 'BuildStartupProject' instance BuildStartupProject = new BuildStartupProject(); // Create 'CompileSingleFile' instance CompileSingleFile = new CompileSingleFile(); // Create 'GenerateProjectFiles' tools GenerateProjectFiles = new GenerateProjectFiles(); // Create Batch Builder tools BatchBuilder = new BatchBuilder(); // Create the project menu quick builder QuickBuilder = new QuickBuild(); // Call parent implementation base.Initialize(); if (DTE.Solution.IsOpen) { StartTicker(); } }
/// IDispose pattern lets us clean up our stuff! protected override void Dispose(bool disposing) { if (Ticker != null && Ticker.IsAlive) { Thread.Sleep(TickPeriod + TickPeriod); if (Ticker.IsAlive) { Logging.WriteLine("WARNING: Force aborting Ticker thread"); Ticker.Abort(); } } base.Dispose(disposing); // Clean up singleton instance PrivateInstance = null; CommandLineEditor = null; StartupProjectSelector = null; BatchBuilder = null; QuickBuilder = null; if (CompileSingleFile != null) { CompileSingleFile.Dispose(); CompileSingleFile = null; } // No longer want solution events if (SolutionEventsHandle != 0) { SolutionManager.UnadviseSolutionEvents(SolutionEventsHandle); SolutionEventsHandle = 0; } SolutionManager = null; // No longer want selection events if (SelectionEventsHandle != 0) { SelectionManager.UnadviseSelectionEvents(SelectionEventsHandle); SelectionEventsHandle = 0; } SelectionManager = null; // No longer want update solution events if (UpdateSolutionEventsHandle != 0) { SolutionBuildManager.UnadviseUpdateSolutionEvents(UpdateSolutionEventsHandle); UpdateSolutionEventsHandle = 0; } SolutionBuildManager = null; Logging.WriteLine("Closing UnrealVS extension"); Logging.Close(); }
/// <summary> /// Initializes the package right after it's been "sited" into the fully-initialized Visual Studio IDE. /// </summary> protected override void Initialize() { Logging.WriteLine("Initializing UnrealVS extension..."); // Grab the MenuCommandService MenuCommandService = GetService( typeof( IMenuCommandService ) ) as OleMenuCommandService; // Get access to Visual Studio's DTE object. This object has various hooks into the Visual Studio // shell that are useful for writing extensions. DTE = (DTE)GetGlobalService( typeof( DTE ) ); Logging.WriteLine("DTE version " + DTE.Version); // Get selection manager and register to receive events SelectionManager = ServiceProvider.GlobalProvider.GetService(typeof (SVsShellMonitorSelection)) as IVsMonitorSelection; SelectionManager.AdviseSelectionEvents( this, out SelectionEventsHandle ); // Get solution and register to receive events SolutionManager = ServiceProvider.GlobalProvider.GetService( typeof( SVsSolution ) ) as IVsSolution2; UpdateUnrealLoadedStatus(); SolutionManager.AdviseSolutionEvents( this, out SolutionEventsHandle ); // Grab the solution build manager. We need this in order to change certain things about the Visual // Studio environment, like what the active startup project is // Get solution build manager SolutionBuildManager = ServiceProvider.GlobalProvider.GetService(typeof (SVsSolutionBuildManager)) as IVsSolutionBuildManager2; SolutionBuildManager.AdviseUpdateSolutionEvents(this, out UpdateSolutionEventsHandle); // Create our command-line editor CommandLineEditor = new CommandLineEditor(); // Create our startup project selector StartupProjectSelector = new StartupProjectSelector(); // Create 'BuildStartupProject' instance BuildStartupProject = new BuildStartupProject(); // Create 'CompileSingleFile' instance CompileSingleFile = new CompileSingleFile(); // Create 'GenerateProjectFiles' tools GenerateProjectFiles = new GenerateProjectFiles(); // Create Batch Builder tools BatchBuilder = new BatchBuilder(); // Create the project menu quick builder QuickBuilder = new QuickBuild(); // Call parent implementation base.Initialize(); if (DTE.Solution.IsOpen) { StartTicker(); } }