Inheritance: PowerStudio.DebugEngine.DebugProgramNode
        /// <summary>
        /// Attaches a debug DebugEngine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
        /// </summary>
        /// <param name="rgpPrograms">An array of IDebugProgram2 objects that represent programs to be attached to. These are port programs.</param>
        /// <param name="rgpProgramNodes">An array of IDebugProgramNode2 objects that represent program nodes, one for each program. The program nodes in this array represent the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to.</param>
        /// <param name="celtPrograms">Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays.</param>
        /// <param name="pCallback">The IDebugEventCallback2 object to be used to send debug events to the SDM.</param>
        /// <param name="dwReason">A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. For more information, see the Remarks section.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise, returns an error code.
        /// </returns>
        public override int Attach( IDebugProgram2[] rgpPrograms,
            IDebugProgramNode2[] rgpProgramNodes,
            uint celtPrograms,
            IDebugEventCallback2 pCallback,
            enum_ATTACH_REASON dwReason)
        {
            Logger.Debug( string.Empty );
            if ( celtPrograms != 1 )
            {
                Debug.Fail( "PowerStudio Engine only expects to see one program in a process." );
                throw new ArgumentException( "celtPrograms" );
            }

            CreateOrInitializeEventSource( pCallback );
            Program = new PowerShellProgramNode( Process );

            EngineEventSource.OnDebugEngineCreate();
            EngineEventSource.OnProgramCreate( Program );
            EngineEventSource.OnLoadComplete();

            return VSConstants.S_OK;
        }
        /// <summary>
        /// Attaches a debug DebugEngine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
        /// </summary>
        /// <param name="rgpPrograms">An array of IDebugProgram2 objects that represent programs to be attached to. These are port programs.</param>
        /// <param name="rgpProgramNodes">An array of IDebugProgramNode2 objects that represent program nodes, one for each program. The program nodes in this array represent the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to.</param>
        /// <param name="celtPrograms">Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays.</param>
        /// <param name="pCallback">The IDebugEventCallback2 object to be used to send debug events to the SDM.</param>
        /// <param name="dwReason">A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. For more information, see the Remarks section.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise, returns an error code.
        /// </returns>
        public override int Attach(IDebugProgram2[] rgpPrograms,
                                   IDebugProgramNode2[] rgpProgramNodes,
                                   uint celtPrograms,
                                   IDebugEventCallback2 pCallback,
                                   enum_ATTACH_REASON dwReason)
        {
            Logger.Debug(string.Empty);
            if (celtPrograms != 1)
            {
                Debug.Fail("PowerStudio Engine only expects to see one program in a process.");
                throw new ArgumentException("celtPrograms");
            }

            CreateOrInitializeEventSource(pCallback);
            Program = new PowerShellProgramNode(Process);

            EngineEventSource.OnDebugEngineCreate();
            EngineEventSource.OnProgramCreate(Program);
            EngineEventSource.OnLoadComplete();

            return(VSConstants.S_OK);
        }