using System; using System.Text.RegularExpressions; namespace Renci.SshNet { /// /// Specifies behavior for expected expression. /// public class ExpectAction { /// /// Gets the expected regular expression. /// public Regex Expect { get; private set; } /// /// Gets the action to perform when expected expression is found. /// public Action Action { get; private set; } /// /// Initializes a new instance of the class. /// /// The expect regular expression. /// The action to perform. /// or is null. public ExpectAction(Regex expect, Action action) { if (expect is null) { throw new ArgumentNullException(nameof(expect)); } if (action is null) { throw new ArgumentNullException(nameof(action)); } Expect = expect; Action = action; } /// /// Initializes a new instance of the class. /// /// The expect expression. /// The action to perform. /// or is null. public ExpectAction(string expect, Action action) { if (expect is null) { throw new ArgumentNullException(nameof(expect)); } if (action is null) { throw new ArgumentNullException(nameof(action)); } Expect = new Regex(Regex.Escape(expect)); Action = action; } } }