PromiseExtensions.cs
131 lines
| 6.1 KiB
| text/x-csharp
|
CSharpLexer
/ Implab / PromiseExtensions.cs
cin
|
r72 | using System.Threading; | ||
cin
|
r75 | using System; | ||
cin
|
r109 | using Implab.Diagnostics; | ||
cin
|
r119 | using System.Collections.Generic; | ||
cin
|
r248 | using System.Linq; | ||
cin
|
r72 | namespace Implab { | ||
public static class PromiseExtensions { | ||||
cin
|
r248 | public static IPromise Then(this IPromise that, Action fulfilled, Action<Exception> rejected) { | ||
var reaction = new PromiseActionReaction(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r101 | } | ||
cin
|
r248 | public static IPromise Then(this IPromise that, Action fulfilled, Func<Exception, IPromise> rejected) { | ||
var reaction = new PromiseActionReaction(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r207 | } | ||
cin
|
r248 | public static IPromise Then(this IPromise that, Func<IPromise> fulfilled, Action<Exception> rejected) { | ||
var reaction = new PromiseActionReaction(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r75 | } | ||
cin
|
r110 | |||
cin
|
r248 | public static IPromise Then(this IPromise that, Func<IPromise> fulfilled, Func<Exception, IPromise> rejected) { | ||
var reaction = new PromiseActionReaction(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r110 | } | ||
cin
|
r119 | |||
cin
|
r248 | public static IPromise Then<T>(this IPromise<T> that, Action<T> fulfilled, Action<Exception> rejected) { | ||
var reaction = new PromiseActionReaction<T>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r205 | } | ||
cin
|
r248 | public static IPromise Then<T>(this IPromise<T> that, Action<T> fulfilled, Func<Exception, IPromise> rejected) { | ||
var reaction = new PromiseActionReaction<T>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r208 | } | ||
cin
|
r248 | public static IPromise Then<T>(this IPromise<T> that, Func<T, IPromise> fulfilled, Action<Exception> rejected) { | ||
var reaction = new PromiseActionReaction<T>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r124 | } | ||
cin
|
r145 | |||
cin
|
r248 | public static IPromise Then<T>(this IPromise<T> that, Func<T, IPromise> fulfilled, Func<Exception, IPromise> rejected) { | ||
var reaction = new PromiseActionReaction<T>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
} | ||||
cin
|
r145 | |||
cin
|
r248 | public static IPromise<Tout> Then<Tout>(this IPromise that, Func<Tout> fulfilled, Func<Exception, Tout> rejected) { | ||
var reaction = new PromiseFuncReaction<Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tout>(this IPromise that, Func<Tout> fulfilled, Func<Exception, IPromise<Tout>> rejected) { | ||
var reaction = new PromiseFuncReaction<Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tout>(this IPromise that, Func<IPromise<Tout>> fulfilled, Func<Exception, Tout> rejected) { | ||
var reaction = new PromiseFuncReaction<Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r207 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tout>(this IPromise that, Func<IPromise<Tout>> fulfilled, Func<Exception, IPromise<Tout>> rejected) { | ||
var reaction = new PromiseFuncReaction<Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tin, Tout>(this IPromise<Tin> that, Func<Tin, Tout> fulfilled, Func<Exception, Tout> rejected) { | ||
var reaction = new PromiseFuncReaction<Tin, Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r207 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tin, Tout>(this IPromise<Tin> that, Func<Tin, Tout> fulfilled, Func<Exception, IPromise<Tout>> rejected) { | ||
var reaction = new PromiseFuncReaction<Tin, Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r207 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tin, Tout>(this IPromise<Tin> that, Func<Tin, IPromise<Tout>> fulfilled, Func<Exception, Tout> rejected) { | ||
var reaction = new PromiseFuncReaction<Tin, Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r207 | } | ||
cin
|
r248 | public static IPromise<Tout> Then<Tin, Tout>(this IPromise<Tin> that, Func<Tin, IPromise<Tout>> fulfilled, Func<Exception, IPromise<Tout>> rejected) { | ||
var reaction = new PromiseFuncReaction<Tin, Tout>(fulfilled, rejected, Promise.DefaultDispatcher); | ||||
that.Then(reaction); | ||||
return reaction.Promise; | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise Catch(this IPromise that, Action<Exception> rejected) { | ||
return Then(that, null, rejected); | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise Catch(this IPromise that, Func<Exception, IPromise> rejected) { | ||
return Then(that, null, rejected); | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise<Tout> Catch<Tout>(this IPromise that, Func<Exception, Tout> rejected) { | ||
return Then(that, (Func<Tout>)null, rejected); | ||||
cin
|
r145 | } | ||
cin
|
r248 | public static IPromise<Tout> Catch<Tout>(this IPromise that, Func<Exception, IPromise<Tout>> rejected) { | ||
return Then(that, (Func<Tout>)null, rejected); | ||||
} | ||||
cin
|
r75 | |||
cin
|
r248 | public static IPromise<Tout> Catch<Tin, Tout>(this IPromise<Tin> that, Func<Exception, Tout> rejected) { | ||
return Then(that, (Func<Tin, Tout>)null, rejected); | ||||
} | ||||
cin
|
r208 | |||
cin
|
r248 | public static IPromise<Tout> Catch<Tin, Tout>(this IPromise<Tin> that, Func<Exception, IPromise<Tout>> rejected) { | ||
return Then(that, (Func<Tin, Tout>)null, rejected); | ||||
} | ||||
cin
|
r72 | } | ||
} | ||||