Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KerlyJiang1 committed Dec 7, 2019
1 parent ea66972 commit e831177
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ public class DeviceControlViewModel : BindableBase
private Switch switchInfo;
private Metric metric;
private DeviceService.DeviceServiceClient client;

public DeviceControlViewModel(DeviceService.DeviceServiceClient client)
{
this.client = client ?? throw new ArgumentNullException(nameof(client));
this.SwitchOnClickCommand = new DelegateCommand<object>(this.ExecuteSwitchOnClickCommand);
this.SwitchOffClickCommand = new DelegateCommand<object>(this.ExecuteSwitchOffClickCommand);
}

public DelegateCommand<string> SwitchOnClickCommand { get; }

public DelegateCommand<string> SwitchOffClickCommand { get; }
public DelegateCommand<object> SwitchOnClickCommand { get; }

public DelegateCommand<object> SwitchOffClickCommand { get; }

public ViewModelContext ViewModelContext
{
Expand Down Expand Up @@ -76,17 +83,17 @@ public async Task UpdateSwitchAsync(Switch switchInfo, FieldMask mask)
this.switchInfo = response;
}

private async void ExecuteSwitchOnClickCommand(string type)
private async void ExecuteSwitchOnClickCommand(object type)
{
FieldMask updateMask = FieldMask.FromString(type);
Switch obj = this.UpdateSwitchInfo(type, true);
FieldMask updateMask = FieldMask.FromString((string)type);
Switch obj = this.UpdateSwitchInfo((string)type, true);
await this.UpdateSwitchAsync(obj, updateMask).ConfigureAwait(true);
}

private async void ExecuteSwitchOffClickCommand(string type)
private async void ExecuteSwitchOffClickCommand(object type)
{
FieldMask updateMask = FieldMask.FromString(type);
Switch obj = this.UpdateSwitchInfo(type, false);
FieldMask updateMask = FieldMask.FromString((string)type);
Switch obj = this.UpdateSwitchInfo((string)type, false);
await this.UpdateSwitchAsync(obj, updateMask).ConfigureAwait(true);
}

Expand Down

0 comments on commit e831177

Please sign in to comment.