/// <summary>
/// The initialize.
/// </summary>
protected override void Initialize()
{
try
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this));
base.Initialize();
this.SetupMenuCommands();
this.dte2 = (DTE2)GetGlobalService(typeof(DTE));
if (this.dte2 == null)
{
return;
}
try
{
this.visualStudioInterface = new VsPropertiesHelper(this.dte2, this);
this.visualStudioInterface.WriteToVisualStudioOutput(DateTime.Now + " : VsSonarExtensionPackage Initialize");
this.VsEvents = new VsEvents(this.visualStudioInterface, this.dte2, this);
var bar = this.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
this.StatusBar = new VSSStatusBar(bar, this.dte2);
var extensionRunningPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty).ToString();
var uniqueId = this.dte2.Version;
if (extensionRunningPath.ToLower().Contains(this.dte2.Version + "exp"))
{
uniqueId += "Exp";
}
SonarQubeViewModelFactory.StartupModelWithVsVersion(uniqueId).InitModelFromPackageInitialization(this.visualStudioInterface, this.StatusBar, this, this.AssemblyDirectory);
this.CloseToolsWindows();
this.OutputGuid = "CDA8E85D-C469-4855-878B-0E778CD0DD" + int.Parse(uniqueId.Split('.')[0]).ToString(CultureInfo.InvariantCulture);
this.StartOutputWindow(this.OutputGuid);
// start listening
SonarQubeViewModelFactory.SQViewModel.PluginRequest += this.LoadPluginIntoNewToolWindow;
this.StartSolutionListeners(this.visualStudioInterface);
// configure colours
DColor defaultBackground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
DColor defaultForeground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey);
SonarQubeViewModelFactory.SQViewModel.UpdateTheme(ToMediaColor(defaultBackground), ToMediaColor(defaultForeground));
}
catch (Exception ex)
{
UserExceptionMessageBox.ShowException("SonarQubeExtension not able to start", ex);
}
}
catch (Exception ex)
{
UserExceptionMessageBox.ShowException("Extension Failed to Start", ex);
throw;
}
}