/// <summary> /// Handles command execution result. /// </summary> /// <param name="callbackId">Command callback identifier on client side</param> /// <param name="result">Execution result</param> private void OnCommandResult(string callbackId, PluginResult result) { #region args checking if (result == null) { Debug.WriteLine("OnCommandResult missing result argument"); return; } if (String.IsNullOrEmpty(callbackId)) { Debug.WriteLine("OnCommandResult missing callbackId argument"); return; } #endregion string status = ((int)result.Result).ToString(); string jsonResult = result.ToJSONString(); ScriptCallback scriptCallback = null; if (String.IsNullOrEmpty(result.Cast)) { scriptCallback = new ScriptCallback("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult }); } else { scriptCallback = new ScriptCallback("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult, result.Cast }); } this.InvokeScriptCallback(scriptCallback); }
/// <summary> /// Handles command execution result. /// </summary> /// <param name="callbackId">Command callback identifier on client side</param> /// <param name="result">Execution result</param> private void OnCommandResult(string callbackId, PluginResult result) { #region args checking if (result == null) { Debug.WriteLine("OnCommandResult missing result argument"); return; } if (String.IsNullOrEmpty(callbackId)) { Debug.WriteLine("OnCommandResult missing callbackId argument"); return; } #endregion string status = ((int)result.Result).ToString(); string jsonResult = result.ToJSONString(); ScriptCallback scriptCallback = null; if (String.IsNullOrEmpty(result.Cast)) { scriptCallback = new ScriptCallback("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult }); } else { scriptCallback = new ScriptCallback("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult, result.Cast }); } this.InvokeScriptCallback(scriptCallback); }
private void InvokeJSSCallback(String callbackId, PluginResult result) { this.Dispatcher.BeginInvoke((ThreadStart)delegate() { if (String.IsNullOrEmpty(callbackId)) { throw new ArgumentNullException("callbackId"); } if (result == null) { throw new ArgumentNullException("result"); } //string callBackScript = result.ToCallbackString(callbackId, "commandResult", "commandError"); // TODO: this is correct invokation method //this.GapBrowser.InvokeScript("eval", new string[] {callBackScript }); /// But we temporary use this version because C#<->JS bridge is on fully ready /// try { string status = ((int)result.Result).ToString(); string jsonResult = result.ToJSONString(); if (String.IsNullOrEmpty(result.Cast)) { this.GapBrowser.InvokeScript("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult }); } else { this.GapBrowser.InvokeScript("PhoneGapCommandResult", new string[] { status, callbackId, jsonResult, result.Cast }); } } catch (Exception ex) { Debug.WriteLine("Exception in InvokeJSSCallback :: " + ex.Message); } }); }
private void InvokeJSSCallback(String callbackId, PluginResult result) { if (String.IsNullOrEmpty(callbackId)) { throw new ArgumentNullException("callbackId"); } if (result == null) { throw new ArgumentNullException("result"); } string callBackScript = result.ToCallbackString(callbackId, "commandResult", "commandError"); // TODO: this is correct invokation method //this.GapBrowser.InvokeScript("eval", new string[] {callBackScript }); /// But we temporary use this version because C#<->JS bridge is not fully ready if (result.IsSuccess) { this.GapBrowser.InvokeScript("commandResult", new string[] { callbackId, result.ToJSONString() }); } else { this.GapBrowser.InvokeScript("commandError", new string[] { callbackId, result.ToJSONString() }); } }