public void Close([Implicit] StepBro.Core.Execution.ICallContext context) { if (context != null && context.LoggingEnabled) { context.Logger.Log(this.GetType().Name, "Close"); } var wasOpen = this.IsOpen; this.DoClose(context); if (this.IsOpen != wasOpen) { this.IsOpenChanged?.Invoke(this, EventArgs.Empty); } }
public bool Open([Implicit] StepBro.Core.Execution.ICallContext context) { var wasOpen = this.IsOpen; if (wasOpen) { if (context != null && context.LoggingEnabled) { context.Logger.Log(this.GetType().Name, "Open (but already open)"); } // TODO: Report error and let script handle it. return(true); } else { if (context != null && context.LoggingEnabled) { context.Logger.Log(this.GetType().Name, "Open"); } try { var result = this.DoOpen(context); if (this.IsOpen != wasOpen) { this.IsOpenChanged?.Invoke(this, EventArgs.Empty); } return(result); } catch (Exception ex) { if (context != null) { context.ReportError($"Could not open stream; {ex.Message}", exception: ex); } return(false); } } }
public static Process Start( [Implicit] StepBro.Core.Execution.ICallContext context, string filename, string arguments = "", TimeSpan startTimeout = new TimeSpan(), TimeSpan exitTimeout = new TimeSpan() // bool moveWindow = false ) { var process = ObjectMonitorManager.Register( new Process((ILogger)context, System.Diagnostics.Process.Start(filename, arguments))); if (startTimeout > TimeSpan.Zero) { if (!process.AwaitStart(context.Logger, startTimeout)) { //context.RegisterResult() return(process); } } return(process); }
public abstract string ReadLine([Implicit] StepBro.Core.Execution.ICallContext context, TimeSpan timeout);
public abstract void Write([Implicit] StepBro.Core.Execution.ICallContext context, string text);
protected abstract void DoClose(StepBro.Core.Execution.ICallContext context);
protected abstract bool DoOpen(StepBro.Core.Execution.ICallContext context);
private string DoSendAfterDelay([Implicit] StepBro.Core.Execution.ICallContext context, string item, TimeSpan delay, string password, int identifier) { return("We sent the \"" + item + "\" after a delay. Keyword: \"" + password + "\". ID: " + identifier.ToString()); }