public void GlobalCleanup() { #if !NO_REMOTING _remotingClient?.Dispose(); _remotingServer?.Dispose(); #endif // !NO_REMOTING }
public void CallContext_should_flow_from_client_to_server_and_back() { var testService = new TestService { TestMethodFake = _ => { CallContext.SetData("test", "Changed"); return(CallContext.GetData("test")); } }; var serverConfig = new ServerConfig() { NetworkPort = 9093, RegisterServicesAction = container => container.RegisterService <ITestService>( factoryDelegate: () => testService, lifetime: ServiceLifetime.Singleton) }; using var server = new RemotingServer(serverConfig); server.Start(); var clientThread = new Thread(() => { CallContext.SetData("test", "CallContext"); var client = new RemotingClient(new ClientConfig() { ServerPort = 9093, ConnectionTimeout = 0 }); client.Connect(); var localCallContextValueBeforeRpc = CallContext.GetData("test"); var proxy = client.CreateProxy <ITestService>(); var result = (string)proxy.TestMethod("x"); var localCallContextValueAfterRpc = CallContext.GetData("test"); Assert.NotEqual(localCallContextValueBeforeRpc, result); Assert.Equal("Changed", result); Assert.Equal("Changed", localCallContextValueAfterRpc); client.Dispose(); }); clientThread.Start(); clientThread.Join(); server.Dispose(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Hide(); Remote.Dispose(); if (TurntableScanner != null) { TurntableScanner.Dispose(); } DeviceManager.CloseKinect(); DeviceManager.Dispose(); Settings.RestoreMetadata(); Settings.Save("Settings.ini"); }
public void RemotingServer_should_register_on_construction_AND_unregister_on_Dispose() { using var server = new RemotingServer(new ServerConfig() { UniqueServerInstanceName = "TestServer" }); Assert.NotNull(RemotingConfiguration.GetRegisteredServer("TestServer")); server.Dispose(); Assert.Null(RemotingConfiguration.GetRegisteredServer("TestServer")); }
public void Connect_should_create_a_proxy_for_a_remote_service() { var testService = new TestService { TestMethodFake = arg => arg }; using var server = new RemotingServer(new ServerConfig { NetworkPort = 9199, IsDefault = true }); RemotingServices.Marshal(testService, "test", typeof(ITestService)); server.Start(); var clientThread = new Thread(() => { // ReSharper disable once ObjectCreationAsStatement new RemotingClient(new ClientConfig { ServerPort = 9199, IsDefault = true }); var proxy = RemotingServices.Connect( typeof(ITestService), "test", string.Empty); Assert.True(RemotingServices.IsTransparentProxy(proxy)); object result = ((ITestService)proxy).TestMethod(1); RemotingClient.DefaultRemotingClient.Dispose(); Assert.Equal(1, Convert.ToInt32(result)); }); clientThread.Start(); clientThread.Join(); server.Dispose(); }