コード例 #1
0
        public DrawingViewModel(IDrawingView view) : base(view)
        {
            view.UpdateRectangleState = UpdateRectangleState;

            _rectangles = new List <Rectangle>();

            _replicationClient = new ReplicationClient <Rectangle>();
            _replicationClient.ObjectReplicated += OnReplicationClientObjectReplicated;
        }
コード例 #2
0
        public void Initialize(string ipAddress, string port, string endpoint)
        {
            var factory = new DuplexChannelFactory <IReplicationClient <R> >(this,
                                                                             new NetTcpBinding()
            {
                OpenTimeout = TimeSpan.MaxValue
            },
                                                                             new EndpointAddress($"net.tcp://{ipAddress}:{port}/ReplicationClient/{endpoint}"));

            proxy = factory.CreateChannel();
        }
コード例 #3
0
        public bool Initialize(string address, string port, string endpoint, IReplicationClient <R> replicationService)
        {
            try
            {
                host = new ServiceHost(replicationService, new Uri($"net.tcp://{address}:{port}"));
                host.AddServiceEndpoint(typeof(IReplicationClient <R>), new NetTcpBinding(), $"ReplicationClient/{endpoint}");
                info = $"net.tcp://{address}:{port}/ReplicationClient/{endpoint}";

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error while initializing replication client host: {e.Message}");
                return(false);
            }
        }