Tp.Integration.Ide.VisualStudio.Connect.OnConnection C# (CSharp) Method

OnConnection() public method

Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.
public OnConnection ( object application, ext_ConnectMode connectMode, object addIn, Array &custom ) : void
application object /// Root object of the host application. ///
connectMode ext_ConnectMode /// Describes how the Add-in is being loaded. ///
addIn object /// Object representing this Add-in. ///
custom System.Array /// Array of parameters that are host application specific. ///
return void
		public void OnConnection(object application, ext_ConnectMode connectMode, object addIn, ref Array custom)
		{
			_application = (DTE2)application;
			_addIn = (AddIn)addIn;
			try
			{
				if (connectMode == ext_ConnectMode.ext_cm_Startup || connectMode == ext_ConnectMode.ext_cm_AfterStartup)
				{
					_listener = CreateTraceListener();
					_env = new ControllerEnvironment(new WindowHandle(_application.MainWindow.HWnd), _listener);
					_controller = CreateController();
					_controller.OnConnectionStateChange += OnConnectionStateChange;
					CreateCommands();
					CreateToolWindow();
					_listener.WriteLine("Addin initialized");
					if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
					{
						OnStartupComplete(ref custom);
					}
				}
			}
			catch (Exception ex)
			{
				if (_listener != null)
				{
					_listener.WriteLine(ex);
				}
			}
		}

Usage Example

		public void TestUiSetupModeConnect()
		{
			var connect = new Connect();
			Array array = null;
			connect.OnConnection(null, ext_ConnectMode.ext_cm_UISetup, null, ref array); // Do nothing.
			connect.OnDisconnection(ext_DisconnectMode.ext_dm_UISetupComplete, ref array); // Do nothing.
		}
All Usage Examples Of Tp.Integration.Ide.VisualStudio.Connect::OnConnection