public string ToJson() { TimeServiceDataContract.DesiredProperties desiredProperties = new TimeServiceDataContract.DesiredProperties(); desiredProperties.enabled = DesiredTimeServiceEnabled.SelectedIndex == 0 ? TimeServiceDataContract.JsonYes : TimeServiceDataContract.JsonNo; desiredProperties.startup = DesiredTimeServiceStartup.SelectedIndex == 0 ? TimeServiceDataContract.JsonAuto : TimeServiceDataContract.JsonManual; desiredProperties.started = DesiredTimeServiceStarted.SelectedIndex == 0 ? TimeServiceDataContract.JsonYes : TimeServiceDataContract.JsonNo; desiredProperties.sourcePriority = DesiredTimeServiceSourcePriority.SelectedIndex == 0 ? PolicyDataContract.JsonLocal : PolicyDataContract.JsonRemote; return(desiredProperties.ToJsonString()); }
/// <summary> /// Set Time Service setting from device twin. /// </summary> private async void SetTimeSettingButton_ClickAsync(object sender, RoutedEventArgs e) { TimeServiceDataContract.DesiredProperties desiredProperties = new TimeServiceDataContract.DesiredProperties(); desiredProperties.enabled = EnabledCombobox.SelectedValue.ToString(); desiredProperties.startup = StartupCombobox.SelectedValue.ToString(); desiredProperties.started = StartedCombobox.SelectedValue.ToString(); desiredProperties.sourcePriority = SourcePriorityCombobox.SelectedValue.ToString(); string refreshingValue = "\"refreshing\""; string finalValue = "{" + desiredProperties.ToJsonString() + "}"; await _mainPage.UpdateTwinData(refreshingValue, finalValue); }