private static void ToggleCrmIntellisense(object sender, EventArgs e, DTE dte) { bool isEnabled; var value = SharedGlobals.GetGlobal("UseCrmIntellisense", dte); if (value == null) { isEnabled = false; SharedGlobals.SetGlobal("UseCrmIntellisense", true, dte); } else { isEnabled = (bool)value; SharedGlobals.SetGlobal("UseCrmIntellisense", !isEnabled, dte); } ExLogger.LogToFile(Logger, $"{Resource.Message_CRMIntellisenseEnabled}: {!isEnabled}", LogLevel.Info); if (!isEnabled) //On { if (HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null) { return; } } else { if (!HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null) { SharedGlobals.SetGlobal("CrmService", null, dte); } CrmMetadata.Metadata = null; SharedGlobals.SetGlobal("CrmMetadata", null, dte); ExLogger.LogToFile(Logger, Resource.Message_ClearingMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_ClearingMetadata, MessageType.Info); return; } var result = MessageBox.Show(Resource.MessageBox_ConnectToCrm, Resource.MessageBox_ConnectToCrm_Title, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result != MessageBoxResult.Yes) { return; } ConnectToCrm(); }