本文整理匯總了C#中WPCordovaClassLib.Cordova.PluginResult.ToJSONString方法的典型用法代碼示例。如果您正苦於以下問題:C# PluginResult.ToJSONString方法的具體用法?C# PluginResult.ToJSONString怎麽用?C# PluginResult.ToJSONString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WPCordovaClassLib.Cordova.PluginResult
的用法示例。
在下文中一共展示了PluginResult.ToJSONString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnCommandResult
/// <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("ERROR: OnCommandResult missing result argument");
return;
}
if (String.IsNullOrEmpty(callbackId))
{
Debug.WriteLine("ERROR: 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("CordovaCommandResult", new string[] { status, callbackId, jsonResult });
}
else
{
scriptCallback = new ScriptCallback("CordovaCommandResult", new string[] { status, callbackId, jsonResult, result.Cast });
}
this.InvokeScriptCallback(scriptCallback);
}
示例2: OnCommandResult
/// <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("ERROR: OnCommandResult missing result argument");
return;
}
if (String.IsNullOrEmpty(callbackId))
{
Debug.WriteLine("ERROR: OnCommandResult missing callbackId argument");
return;
}
if (!String.IsNullOrEmpty(result.CallbackId) && callbackId != result.CallbackId)
{
Debug.WriteLine("Multiple Overlapping Results :: " + result.CallbackId + " :: " + callbackId);
return;
}
#endregion
string jsonResult = result.ToJSONString();
string callback;
string args = string.Format("('{0}',{1});", callbackId, jsonResult);
if (result.Result == PluginResult.Status.NO_RESULT ||
result.Result == PluginResult.Status.OK)
{
callback = @"(function(callbackId,args) {
try { args.message = JSON.parse(args.message); } catch (ex) { }
cordova.callbackSuccess(callbackId,args);
})" + args;
}
else
{
callback = @"(function(callbackId,args) {
try { args.message = JSON.parse(args.message); } catch (ex) { }
cordova.callbackError(callbackId,args);
})" + args;
}
this.InvokeScriptCallback(new ScriptCallback("eval", new string[] { callback }));
}