WP7GapClassLib.PhoneGap.PluginResult.ToJSONString C# (CSharp) Method

ToJSONString() public method

public ToJSONString ( ) : string
return string
        public string ToJSONString()
        {
            string res = String.Format("\"status\":{0},\"message\":{1},\"keepCallback\":{2}",
                (int)this.Result,
                this.Message,
                this.KeepCallback.ToString().ToLower() );

            res = "{" + res + "}";
            return res;
        }

Usage Example

Ejemplo n.º 1
0
        /// <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);
        }
All Usage Examples Of WP7GapClassLib.PhoneGap.PluginResult::ToJSONString