当前位置: 首页>>代码示例>>C#>>正文


C# PluginResult.ToJSONString方法代码示例

本文整理汇总了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);
        }
开发者ID:KodkodGates,项目名称:BoochReader,代码行数:39,代码来源:NativeExecution.cs

示例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 }));

        }
开发者ID:Guepardo,项目名称:dlPc_app,代码行数:52,代码来源:NativeExecution.cs


注:本文中的WPCordovaClassLib.Cordova.PluginResult.ToJSONString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。