CommandArgs.Context
property · CommandArgs · cAlgo.API
DesktopCLICloud
Gets the context in which the command is executed.
Environment behaviour
CLI — not supported. Available to plugins only, and plugins cannot run in the CLI.
Cloud — not supported. Available to plugins only, and plugins cannot run in the cloud.
Definition
public object Context {get;}
commandArgs.Context: object
Returns object
Examples
protected override void OnStart()
{
Commands.Add(CommandType.ChartContainerToolbar, OnCommandExecuted);
}
private void OnCommandExecuted(CommandArgs args)
{
if (args.Context is ChartContainer chartContainer)
Print("Executed from chart container {0}", chartContainer.Id);
}
from System import Action
def on_start(self):
api.Commands.Add(CommandType.ChartContainerToolbar, Action[CommandArgs](self.on_command_executed))
def on_command_executed(self, args):
api.Print(f"Command context: {args.Context}")