...
Code Block | ||
---|---|---|
| ||
using Connexion.Core; using System.Threading.Tasks; using System.Windows.Input; namespace ProxySample1 { public class ProxySample1UIViewModel : ViewModelBase { private ProxySample1Configuration m_Config; private IDeviceUIParams m_DeviceUIParams; private IDiagnostics m_Proxy; public ProxySample1UIViewModel(ProxySample1Configuration config, IDeviceUIParams deviceUIParams) { m_Config = config; m_DeviceUIParams = deviceUIParams; m_Proxy = deviceUIParams.GetServerDeviceProxy<IDiagnostics>(); // <-- creation of the proxy } public ProxySample1Configuration Configuration { get { return m_Config; } } private RelayCommand m_GetDiagnosticsCommand; public ICommand GetDiagnosticsCommand { get { return m_GetDiagnosticsCommand ?? (m_GetDiagnosticsCommand = new RelayCommand(async p => await GetDiagnostics())); } } private async Task GetDiagnostics() { await Task.Run(() => { try { DiagnosticResult = await m_Proxy.GetDiagnostics(); // <-- Calling the server } catch(exception ex) { DiagnosticResult = ex.Message; }); } private string m_DiagnosticResult = "Click to run the diagnostics"; public string DiagnosticResult { get { return m_DiagnosticResult; } set { if(m_DiagnosticResult != value) { m_DiagnosticResult = value; RaisePropertyChanged(); } } } } } |
...