This project is read-only.
List of ScriptCommands
IScriptCommand a interface for is a piece of work to run using ScriptRunner.

public interface IScriptCommand
{
    string CommandKey { get; }

    IScriptCommand Execute(ParameterDic pm);
    Task<IScriptCommand> ExecuteAsync(ParameterDic pm);

    bool CanExecute(ParameterDic pm);
}


Most implementer of IScriptCommand inherited from ScriptCommandBase, which have it's Execute() calls ExecuteAsync() in a Synchronous way and vice versa, so one only have to override Execute() or ExecuteAsync() method.

Both Execute() and ExecuteAsync() takes a ParameterDic object, which is a Dictionary<string, object> and store state information for next command to use.

Using ScriptCommand you can define your complex code in separate class, and reuse them in different place, e.g. Open command in FileList:
ScriptCommands.Open = FileList.IfSelection(evm => evm.Count() == 1,
           FileList.IfSelection(evm => evm[0].EntryModel.IsDirectory,
             FileList.OpenSelectedDirectory,  //Selected directory
             ResultCommand.NoError),   //Selected non-directory
           ResultCommand.NoError //Selected more than one item.                   
);


For one line code one can use SimpleScriptCommand as well.
            new SimpleScriptCommand("DoSomething",
                        pd => Debug.WriteLine("Test"));

Last edited Mar 7, 2014 at 3:01 PM by lycj, version 5

Comments

No comments yet.