Beispiel #1
0
        public static T Create <T>(INodeEndpointClientProvider provider)
            where T : INodeEndpointClient
        {
            Type clientType = CreateClientImplementation(typeof(T));

            return((T)clientType
                   .GetConstructor(new Type[] { typeof(INodeEndpointClientProvider) })
                   .Invoke(new object[] { provider }));
        }
Beispiel #2
0
        private void ConnectionThreadProc(string address, string endpointName)
        {
            bool aborted = false;

            try
            {
                INodeEndpointProtocolClient client = this.Reflector.Factory.CreateClient();
                if (client.Connect(address, endpointName, 5000))
                {
                    this.protocolClient          = client;
                    this.clientProvider          = new ProtocolEnabledClientProvider();
                    this.clientProvider.Protocol = this.protocolClient;
                    this.protocolClient.BeginListen();
                }
            }
            catch (ThreadAbortException)
            {
                aborted = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Connecting Service");
            }

            if (!aborted)
            {
                this.Invoke(new MethodInvoker(() =>
                {
                    if (this.clientProvider == null)
                    {
                        labelConnectionState.Text = "Failed to connect.";
                        buttonConnect.Enabled     = true;
                    }
                    else
                    {
                        labelConnectionState.Text = "Connected to the service.";
                        buttonSend.Enabled        = true;
                    }
                    this.connectionThread = null;
                }));
            }
        }
 public StrongTypedNodeEndpointClient(INodeEndpointClientProvider provider)
 {
     this.Provider = provider;
 }