public void stopWatch(string options) { try { compassOptions = JSON.JsonHelper.Deserialize <CompassOptions>(options); } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } if (string.IsNullOrEmpty(compassOptions.Id)) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } if (currentStatus != Stopped) { lock (compass) { Compass watcher = watchers[compassOptions.Id]; compass.CurrentValueChanged -= watcher.compass_CurrentValueChanged; watchers.Remove(compassOptions.Id); watcher.Dispose(); } } this.SetStatus(Stopped); this.DispatchCommandResult(); }
public void startWatch(string options) { if (!DeviceCompass.IsSupported) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported)); } try { compassOptions = JSON.JsonHelper.Deserialize <CompassOptions>(options); } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } if (string.IsNullOrEmpty(compassOptions.Id)) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } try { lock (compass) { watchers.Add(compassOptions.Id, this); compass.CurrentValueChanged += watchers[compassOptions.Id].compass_CurrentValueChanged; compass.Start(); this.SetStatus(Starting); } } catch (Exception) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart)); return; } }
public void stopWatch(string options) { try { compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options); } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } if (string.IsNullOrEmpty(compassOptions.Id)) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } if (currentStatus != Stopped) { lock (compass) { Compass watcher = watchers[compassOptions.Id]; compass.CurrentValueChanged -= watcher.compass_CurrentValueChanged; watchers.Remove(compassOptions.Id); watcher.Dispose(); } } this.SetStatus(Stopped); this.DispatchCommandResult(); }
public void startWatch(string options) { if (!DeviceCompass.IsSupported) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, Not_Supported)); } try { compassOptions = JSON.JsonHelper.Deserialize<CompassOptions>(options); } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } if (string.IsNullOrEmpty(compassOptions.Id)) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } try { lock (compass) { watchers.Add(compassOptions.Id, this); compass.CurrentValueChanged += watchers[compassOptions.Id].compass_CurrentValueChanged; compass.Start(); this.SetStatus(Starting); } } catch (Exception) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ErrorFailedToStart)); return; } }