lib/windows-phone-8/templates/standalone/cordovalib/NativeExecution.cs
/// <summary>
/// Executes command and returns result back.
/// </summary>
/// <param name="commandCallParams">Command to execute</param>
Executes command and returns result back.
Executes command and returns result back .
public void ProcessCommand(CordovaCommandCall commandCallParams)
        {
            if (commandCallParams == null)
            {
                throw new ArgumentNullException("commandCallParams");
            }
            try
            {
                BaseCommand bc = CommandFactory.CreateByServiceName(commandCallParams.Service);
                if (bc == null)
                {
                    this.OnCommandResult(commandCallParams.CallbackId, new PluginResult(PluginResult.Status.CLASS_NOT_FOUND_EXCEPTION));
                    return;
                }
                EventHandler<PluginResult> OnCommandResultHandler = delegate(object o, PluginResult res)
                {
                    this.OnCommandResult(commandCallParams.CallbackId, res);
                };
                bc.OnCommandResult += OnCommandResultHandler;
                EventHandler<ScriptCallback> OnCustomScriptHandler = delegate(object o, ScriptCallback script)
                {
                    this.InvokeScriptCallback(script);
                };
                bc.OnCustomScript += OnCustomScriptHandler;
                ThreadStart methodInvokation = () =>
                {
                    try
                    {
                        bc.InvokeMethodNamed(commandCallParams.Action, commandCallParams.Args);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("ERROR: Exception in ProcessCommand :: " + ex.Message);
                        bc.OnCommandResult -= OnCommandResultHandler;
                        bc.OnCustomScript -= OnCustomScriptHandler;
                        Debug.WriteLine("ERROR: failed to InvokeMethodNamed :: " + commandCallParams.Action + " on Object :: " + commandCallParams.Service);
                        this.OnCommandResult(commandCallParams.CallbackId, new PluginResult(PluginResult.Status.INVALID_ACTION));
                        return;
                    }
                };
                if ((bc is File) || (bc is Accelerometer))
                {
                    methodInvokation.Invoke();
                }
                else
                {
                    new Thread(methodInvokation).Start();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("ERROR: Unable to execute command :: {0}:{1}:{3} ",
                    commandCallParams.Service, commandCallParams.Action, ex.Message));
                this.OnCommandResult(commandCallParams.CallbackId, new PluginResult(PluginResult.Status.ERROR));
                return;
            }
        }
public void ProcessCommand ( CordovaCommandCall commandCallParams ) { if ( commandCallParams == null ) { throw new ArgumentNullException ( " " ) ; } try { BaseCommand bc = CommandFactory . CreateByServiceName ( commandCallParams . Service ) ; if ( bc == null ) { this . OnCommandResult ( commandCallParams . CallbackId , new PluginResult ( PluginResult . Status . CLASS_NOT_FOUND_EXCEPTION ) ) ; return ; } EventHandler < PluginResult > OnCommandResultHandler = delegate ( object o , PluginResult res ) { this . OnCommandResult ( commandCallParams . CallbackId , res ) ; } ; bc . OnCommandResult += OnCommandResultHandler ; EventHandler < ScriptCallback > OnCustomScriptHandler = delegate ( object o , ScriptCallback script ) { this . InvokeScriptCallback ( script ) ; } ; bc . OnCustomScript += OnCustomScriptHandler ; ThreadStart methodInvokation = ( ) => { try { bc . InvokeMethodNamed ( commandCallParams . Action , commandCallParams . Args ) ; } catch ( Exception ex ) { Debug . WriteLine ( " " + ex . Message ) ; bc . OnCommandResult -= OnCommandResultHandler ; bc . OnCustomScript -= OnCustomScriptHandler ; Debug . WriteLine ( " " + commandCallParams . Action + " " + commandCallParams . Service ) ; this . OnCommandResult ( commandCallParams . CallbackId , new PluginResult ( PluginResult . Status . INVALID_ACTION ) ) ; return ; } } ; if ( ( bc is File ) || ( bc is Accelerometer ) ) { methodInvokation . Invoke ( ) ; } else { new Thread ( methodInvokation ) . Start ( ) ; } } catch ( Exception ex ) { Debug . WriteLine ( String . Format ( " " , commandCallParams . Service , commandCallParams . Action , ex . Message ) ) ; this . OnCommandResult ( commandCallParams . CallbackId , new PluginResult ( PluginResult . Status . ERROR ) ) ; return ; } }
Executes command and returns result back.
Executes command and returns result back .
// Due to some issues with the IsolatedStorage in current version of WP8 SDK we have to run all File Api commands synchronously. // TODO: test this in WP8 RTM // ERROR
commandCallParams
CordovaCommandCall
Command to execute
Command to execute