| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Text.RegularExpressions;
- namespace Renci.SshNet
- {
- /// <summary>
- /// Specifies behavior for expected expression
- /// </summary>
- public class ExpectAction
- {
- /// <summary>
- /// Gets the expected regular expression.
- /// </summary>
- public Regex Expect { get; private set; }
- /// <summary>
- /// Gets the action to perform when expected expression is found.
- /// </summary>
- public Action<string> Action { get; private set; }
- /// <summary>
- /// Initializes a new instance of the <see cref="ExpectAction"/> class.
- /// </summary>
- /// <param name="expect">The expect regular expression.</param>
- /// <param name="action">The action to perform.</param>
- /// <exception cref="ArgumentNullException"><paramref name="expect"/> or <paramref name="action"/> is null.</exception>
- public ExpectAction(Regex expect, Action<string> action)
- {
- if (expect == null)
- throw new ArgumentNullException("expect");
- if (action == null)
- throw new ArgumentNullException("action");
- this.Expect = expect;
- this.Action = action;
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="ExpectAction"/> class.
- /// </summary>
- /// <param name="expect">The expect expression.</param>
- /// <param name="action">The action to perform.</param>
- /// <exception cref="ArgumentNullException"><paramref name="expect"/> or <paramref name="action"/> is null.</exception>
- public ExpectAction(string expect, Action<string> action)
- {
- if (expect == null)
- throw new ArgumentNullException("expect");
- if (action == null)
- throw new ArgumentNullException("action");
- this.Expect = new Regex(Regex.Escape(expect));
- this.Action = action;
- }
- }
- }
|