using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.ObjectModel; namespace Tor.Controller { /// /// A class containing information regarding a response received back from a control connection. /// internal sealed class ConnectionResponse { private readonly StatusCode code; private readonly ReadOnlyCollection responses; /// /// Initializes a new instance of the class. /// /// The status code returned by the control connection. public ConnectionResponse(StatusCode code) { this.code = code; this.responses = new List().AsReadOnly(); } /// /// Initializes a new instance of the class. /// /// The status code returned by the control connection. /// The responses received back from the control connection. public ConnectionResponse(StatusCode code, IList responses) { this.code = code; this.responses = new ReadOnlyCollection(responses); } #region Properties /// /// Gets a read-only collection of responses received from the control connection. /// public ReadOnlyCollection Responses { get { return responses; } } /// /// Gets the status code returned with the response. /// public StatusCode StatusCode { get { return code; } } /// /// Gets a value indicating whether the response was successful feedback. /// public bool Success { get { return code == StatusCode.OK; } } #endregion } }