##// END OF EJS Templates
Working on Unity container xml configuration
Working on Unity container xml configuration

File last commit:

r249:d82909310094 v3
r270:ade80d94dfb5 v3
Show More
PromiseFuncReaction`1.cs
90 lines | 3.2 KiB | text/x-csharp | CSharpLexer
/ Implab / PromiseFuncReaction`1.cs
cin
working on promises
r247 using System;
using System.Diagnostics;
namespace Implab {
cin
Implab.Test moved to xunit...
r249 class PromiseFuncReaction<TRet> : IResolvable {
cin
working on promises
r247 readonly Deferred<TRet> m_next;
cin
Implab.Test moved to xunit...
r249 readonly IDispatcher m_dispatcher;
readonly Action<Deferred<TRet>> m_fulfilled;
readonly Action<Exception, Deferred<TRet>> m_rejected;
cin
Added awaiters to promises...
r248 public IPromise<TRet> Promise {
get { return m_next.Promise; }
}
cin
Implab.Test moved to xunit...
r249 public PromiseFuncReaction(Action<Deferred<TRet>> fulfilled, Action<Exception, Deferred<TRet>> rejected, Deferred<TRet> next, IDispatcher dispatcher) {
m_next = next;
m_fulfilled = fulfilled;
m_rejected = rejected;
m_dispatcher = dispatcher;
cin
working on promises
r247 }
cin
Implab.Test moved to xunit...
r249 public void Resolve() {
if (m_fulfilled != null) {
if (m_dispatcher != null)
m_dispatcher.Enqueue(ResolveImpl);
else
ResolveImpl();
} else {
m_next.Resolve(default(TRet));
}
}
cin
Added awaiters to promises...
r248
cin
Implab.Test moved to xunit...
r249 void ResolveImpl () {
m_fulfilled(m_next);
}
public void Reject(Exception error) {
if (m_fulfilled != null) {
if (m_dispatcher != null)
m_dispatcher.Enqueue(RejectImpl, error);
else
RejectImpl(error);
} else {
m_next.Reject(error);
}
cin
working on promises
r247 }
cin
Implab.Test moved to xunit...
r249 void RejectImpl(Exception error) {
m_rejected(error, m_next);
}
cin
Added awaiters to promises...
r248
cin
Implab.Test moved to xunit...
r249 public static PromiseFuncReaction<TRet> Create(Func<TRet> fulfilled, Func<Exception, TRet> rejected, IDispatcher dispatcher) {
return new PromiseFuncReaction<TRet>(
fulfilled != null ? PromiseHandler.Create(fulfilled) : null,
rejected != null ? PromiseHandler.Create(rejected) : null,
new Deferred<TRet>(),
dispatcher
);
cin
working on promises
r247 }
cin
Implab.Test moved to xunit...
r249 public static PromiseFuncReaction<TRet> Create(Func<IPromise<TRet>> fulfilled, Func<Exception, TRet> rejected, IDispatcher dispatcher) {
return new PromiseFuncReaction<TRet>(
fulfilled != null ? PromiseHandler.Create(fulfilled) : null,
rejected != null ? PromiseHandler.Create(rejected) : null,
new Deferred<TRet>(),
dispatcher
);
cin
Added awaiters to promises...
r248 }
cin
working on promises
r247
cin
Implab.Test moved to xunit...
r249 public static PromiseFuncReaction<TRet> Create(Func<TRet> fulfilled, Func<Exception, IPromise<TRet>> rejected, IDispatcher dispatcher) {
return new PromiseFuncReaction<TRet>(
fulfilled != null ? PromiseHandler.Create(fulfilled) : null,
rejected != null ? PromiseHandler.Create(rejected) : null,
new Deferred<TRet>(),
dispatcher
);
cin
working on promises
r247 }
cin
Implab.Test moved to xunit...
r249 public static PromiseFuncReaction<TRet> Create(Func<IPromise<TRet>> fulfilled, Func<Exception, IPromise<TRet>> rejected, IDispatcher dispatcher) {
return new PromiseFuncReaction<TRet>(
fulfilled != null ? PromiseHandler.Create(fulfilled) : null,
rejected != null ? PromiseHandler.Create(rejected) : null,
new Deferred<TRet>(),
dispatcher
);
cin
working on promises
r247 }
}
}