namespace Caliburn.Micro.Core {
using System;
///
/// A simple result.
///
public sealed class SimpleResult : IResult {
readonly bool wasCancelled;
readonly Exception error;
private SimpleResult(bool wasCancelled, Exception error) {
this.wasCancelled = wasCancelled;
this.error = error;
}
///
/// A result that is always succeeded.
///
public static IResult Succeeded() {
return new SimpleResult(false, null);
}
///
/// A result that is always canceled.
///
/// The result.
public static IResult Cancelled() {
return new SimpleResult(true, null);
}
///
/// A result that is always failed.
///
public static IResult Failed(Exception error) {
return new SimpleResult(false, error);
}
///
/// Executes the result using the specified context.
///
/// The context.
public void Execute(CoroutineExecutionContext context) {
Completed(this, new ResultCompletionEventArgs {WasCancelled = wasCancelled, Error = error});
}
///
/// Occurs when execution has completed.
///
public event EventHandler Completed = delegate { };
}
}