This class implements a port. It implements: - IDebugPort2 - This interface represents a debug port on a machine. (http://msdn.microsoft.com/en-us/library/bb147021.aspx) - IConnectionPointContainer - Supports connection points for connectable objects. Indicates to a client that the object is connectable and provides the IConnectionPoint interface. (http://msdn.microsoft.com/en-CA/library/ms683857.aspx) - IConnectionPoint - Supports connection points for connectable objects. (http://msdn.microsoft.com/en-us/library/ms694318.aspx)
Inheritance: IDebugPort2
Exemplo n.º 1
0
        /// <summary>
        /// Adds a port. (http://msdn.microsoft.com/en-ca/library/bb161980.aspx)
        /// </summary>
        /// <param name="pRequest"> An IDebugPortRequest2 object that describes the port to be added. </param>
        /// <param name="ppPort"> Returns an IDebugPort2 object that represents the port. </param>
        /// <returns> VSConstants.S_OK. </returns>
        public int AddPort(IDebugPortRequest2 pRequest, out IDebugPort2 ppPort)
        {
            bool sucess = true;
            AD7PortRequest port_request = null;
            AD7Port port = null;
            try
            {
                port_request = (AD7PortRequest)pRequest;
            }
            catch
            {
                sucess = false;
                string portRequestName;
                AD7Port defaultPort = null;
                pRequest.GetPortName(out portRequestName);
                string search = "";
                if (portRequestName.ToLower().Contains("device"))
                    search = "device";
                else if (portRequestName.ToLower().Contains("simulator"))
                    search = "simulator";
                else
                {
                    search = portRequestName.ToLower();
                }
                foreach (var p in m_ports)
                {
                    AD7Port tempPort = p.Value;
                    if (defaultPort == null)
                        defaultPort = tempPort;

                    string tempPortName = "";
                    tempPort.GetPortName(out tempPortName);
                    if (tempPortName.ToLower().Contains(search))
                    {
                        port = tempPort;
                        break;
                    }
                    else
                    {
                        string IP = search;
                        do
                        {
                            int pos = IP.LastIndexOf('.');
                            if (pos != -1)
                            {
                                IP = IP.Remove(pos);
                                if (tempPortName.Contains(IP))
                                {
                                    port = tempPort;
                                    break;
                                }
                            }
                            else
                                IP = "";
                        } while (IP != "");
                        if (IP != "")
                            break;
                    }
                }
                if (port == null)
                {
                    if (defaultPort != null)
                    {
                        port = defaultPort;
                    }
                    else
                        port = new AD7Port(this, port_request, Guid.NewGuid(), "", "", true, "");
                }
            }
            if (sucess)
            {
                port = CreatePort(port_request);
                Guid portGuid;
                port.GetPortId(out portGuid);
                m_ports.Add(portGuid, port);
            }
            ppPort = port;
            return VSConstants.S_OK;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Detaches the debugger from this process by detaching all of the programs in the process. 
 /// (http://msdn.microsoft.com/en-us/library/bb162197.aspx)
 /// </summary>
 /// <returns> VSConstants.S_OK. </returns>
 public int Detach()
 {
     _port = null;
     _portAttach = null;
     _engine = null;
     m_program = null;
     return VSConstants.S_OK;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieves a list of all the ports supplied by a port supplier. (http://msdn.microsoft.com/en-ca/library/bb146984.aspx)
        /// </summary>
        /// <param name="ppEnum"> Returns an IEnumDebugPorts2 object containing a list of ports supplied. </param>
        /// <returns> VSConstants.S_OK. </returns>
        public int EnumPorts(out IEnumDebugPorts2 ppEnum)
        {
            m_ports.Clear();
            int success = verifyAndAddPorts();
            AD7Port[] ports = new AD7Port[m_ports.Count()];

            if (m_ports.Count() > 0)
            {
                int i = 0;
                foreach (var p in m_ports)
                {
                    ports[i] = p.Value;
                    i++;
                }
            }
            else
            {
                if (success == 0)
                    MessageBox.Show("Visual Studio can debug only one BlackBerry application at a time.\n\nPlease, select a different transport or close the current debug session.", "Visual Studio is already debugging an application", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else if (success == -1)
                    MessageBox.Show("You must select an API Level to be able to attach to a running process.\n\nPlease, use \"BlackBerry -> Settings -> Get more\" to download one.", "Missing NDK", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else
                    MessageBox.Show("Missing Device/Simulator information. Please, use menu BlackBerry -> Settings to add any of those information.", "Missing Device/Simulator Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            ppEnum = new AD7PortEnum(ports);
            return VSConstants.S_OK;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="aPort"> The AD7Port object that represents the port used in Attach to Process UI. </param>
 /// <param name="ID"> The process ID. </param>
 /// <param name="name"> The process name. </param>
 public AD7Process(AD7Port aPort, string ID, string name)
 {
     _portAttach = aPort;
     _processID = ID;
     _name = name;
 }