Пример #1
0
        // Creates the WPF window and stores integration information.
        public MainWindow(string host, 
            int port,
            string path,
            string args,
            string connectionName,
            string parentAppUuid,
            string name,
            string url)
        {
            // Store connection & integration information
            host_ = host;
            port_ = port;
            parentAppUuid_ = parentAppUuid;
            name_ = name;
            path_ = path;
            args_ = args;
            connectionName_ = connectionName;
            url_ = url;

            // Create the connection with a unique name
            connection_ = new DesktopConnection(connectionName, host, port);

            // Register handler on load for registering this window with the desktop
            this.Loaded += MainWindow_Loaded;

            InitializeComponent();
        }
Пример #2
0
        public static Connection CreateConnection(string type, string name, int price)
        {
            Connection connection;

            switch (type)
            {
            case "WirelessConnection":
                connection = new WirelessConnection(name, price);
                break;

            case "WiredConnection":
                connection = new WiredConnection(name, price);
                break;

            case "DesktopConnection":
                connection = new DesktopConnection(name, price);
                break;

            case "NicConnection":
                connection = new NicConnection(name, price);
                break;

            default:
                throw new ArgumentException("Unrecognized connection type.");
            }
            return(connection);
        }
Пример #3
0
        // Creates the WPF window and stores integration information.
        public MainWindow(string host,
                          int port,
                          string path,
                          string args,
                          string connectionName,
                          string parentAppUuid,
                          string name,
                          string url)
        {
            // Store connection & integration information
            host_           = host;
            port_           = port;
            parentAppUuid_  = parentAppUuid;
            name_           = name;
            path_           = path;
            args_           = args;
            connectionName_ = connectionName;
            url_            = url;

            // Create the connection with a unique name
            connection_ = new DesktopConnection(connectionName, host, port);

            // Register handler on load for registering this window with the desktop
            this.Loaded += MainWindow_Loaded;

            InitializeComponent();
        }
Пример #4
0
 public Form1()
 {
     InitializeComponent();
     //setConnectButtonState("Connect", true, false);
     subscriptionMap = new Dictionary<string, bool>();
     controller_ = new DesktopConnection(uuid_, "127.0.0.1", 9696);
     this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(formClosedHandler);
 }
Пример #5
0
 public Form1()
 {
     InitializeComponent();
     //setConnectButtonState("Connect", true, false);
     subscriptionMap  = new Dictionary <string, bool>();
     controller_      = new DesktopConnection(uuid_, "127.0.0.1", 9696);
     this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(formClosedHandler);
 }
Пример #6
0
        public void TestInitialization()
        {
            DesktopConnection connection = new DesktopConnection("Desktop", 10);

            Assert.AreEqual("Desktop", connection.ConnectionTypeName);
            Assert.AreEqual(10, connection.Price);
            Assert.IsFalse(String.IsNullOrEmpty(connection.GetDetailedInfoString()));
        }
Пример #7
0
        /// <summary>
        ///     Creates the WPF window and establishes a websocket connection.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // Create and connect
            connection_ = new DesktopConnection("C# InterApplicationBus Example", "localhost", 9696);
            connection_.connect(this);
        }
Пример #8
0
        /// <summary>
        ///     Creates the WPF window and establishes a websocket connection.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // Create and connect
            connection_ = new DesktopConnection("C# InterApplicationBus Example", "localhost", 9696);
            connection_.connect(this);
        }
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DesktopConnection connection = ((ConnectionListViewItem)connectionsListView.SelectedItems[0]).Connection as DesktopConnection;

            if (connection != null)
            {
                connection.Connect();
            }
        }
Пример #10
0
        public void CanConnectAndDisconnect()
        {
            DesktopConnection connection = new DesktopConnection("Desktop", 10);

            connection.Connect();
            Assert.IsTrue(connection.IsConnected);

            connection.Disconnect();
            Assert.IsFalse(connection.IsConnected);
        }
Пример #11
0
        public void TestAddConnectionsThroughMonitor()
        {
            DesktopConnection objDesktop = new DesktopConnection("Test", 100);
            NicConnection     objNIC     = new WiredConnection("Local Area Connection", 100);
            Connection        objConn1   = objNIC;
            ConnectionMonitor objConMonitor1;

            objConMonitor1 = new ConnectionMonitor();
            ConnectionCollection objConnColl1 = objConMonitor1.Connections;

            objConnColl1.Add(objDesktop);
            objConnColl1.Add(objNIC);
            objConnColl1.Add(objConn1);
        }
Пример #12
0
        /// <summary>
        /// Creates a <see cref="Connection"/> object.
        /// </summary>
        /// <param name="connectionType">The type of the connection to create.</param>
        /// <param name="price">The price of the <see cref="Connection"/>.</param>
        /// <returns>A <see cref="Connection"/> object.</returns>
        /// <exception cref="ConnectionMonitorException">Thrown when an invalid type is requested.</exception>
        /// <remarks>
        /// For the built-in <see cref="Connection"/> types
        /// (i.e. DesktopConnection, NicConnection, WirelessConnection, WiredConnection),
        /// only the class name is required.  For user created types, the fully qualified
        /// class name is required.
        /// </remarks>
        public static Connection CreateConnection(string connectionType, int price)
        {
            Guard.StringNotNullOrEmpty(connectionType, "connectionType");

            if (price < 0)
            {
                throw new ArgumentOutOfRangeException("price");
            }

            Connection connection;

            switch (connectionType)
            {
            case DesktopConnection:
                connection = new DesktopConnection(DesktopConnection, price);
                break;

            case NicConnection:
                connection = new NicConnection(NicConnection, price);
                break;

            case WirelessConnection:
                connection = new WirelessConnection(WirelessConnection, price);
                break;

            case WiredConnection:
                connection = new WiredConnection(WiredConnection, price);
                break;

            default:
                try
                {
                    Type   connectionTypeToCreate = Type.GetType(connectionType, true);
                    Object createdObject          = Activator.CreateInstance(connectionTypeToCreate, connectionTypeToCreate.Name, price);
                    connection = createdObject as Connection;
                }
                catch (TypeLoadException ex)
                {
                    throw new ConnectionMonitorException("Unsupported connection type.", ex);
                }

                if (connection == null)
                {
                    throw new ConnectionMonitorException("Unsupported connection type.");
                }
                break;
            }
            return(connection);
        }
Пример #13
0
        public void DisconnectRaisesStateChangeEvent()
        {
            DesktopConnection connection = new DesktopConnection("Desktop", 10);

            bool   isConnected = true;
            string networkName = string.Empty;
            EventHandler <StateChangedEventArgs> handler =
                new EventHandler <StateChangedEventArgs>(
                    delegate(object sender, StateChangedEventArgs args) { isConnected = args.IsConnected; });

            connection.StateChanged += handler;
            connection.Disconnect();

            Assert.IsFalse(isConnected);
        }
Пример #14
0
        public void DesktopConnectionIsConnection()
        {
            DesktopConnection connection = new DesktopConnection("Desktop", 0);

            Assert.IsTrue(connection is Connection);
        }