using System; namespace Umbraco.Core { /// /// Represents the result of an operation attempt /// /// /// [Serializable] public struct Attempt { private readonly bool _success; private readonly T _result; private readonly Exception _error; /// /// Gets a value indicating whether this represents a successful operation. /// /// public bool Success { get { return _success; } } /// /// Gets the error associated with an unsuccessful attempt. /// /// The error. public Exception Error { get { return _error; } } /// /// Gets the parse result. /// /// public T Result { get { return _result; } } /// /// Represents an unsuccessful parse operation /// public static readonly Attempt False = new Attempt(false, default(T)); /// /// Initializes a new instance of the struct. /// /// If set to true this tuple represents a successful parse result. /// The parse result. /// public Attempt(bool success, T result) { _success = success; _result = result; _error = null; } public Attempt(Exception error) { _success = false; _result = default(T); _error = error; } } }