internal Scope(PromiseFactory factory, DefinitionBag defs) { this._factory = factory; this._last = null; this._defs = new DefinitionBag(defs); this._result = factory.CreateManual <ControlValue <T> >(); }
public Promise <MockScene> Load(string sceneName) { const float delay = 3; Debug.Log(string.Format("SceneLoader.Load - init scene loading delay by {1}s. SceneName={0}", sceneName, delay)); var scene = new MockScene { SceneName = sceneName, GameObjects = new List <string> { "_app", "floor", "main camera" } }; //return TaskFactory.StartNewDelayed(() => scene, delay); return(PromiseFactory.StartNewDeferred <MockScene>(x => { //x.Reject(System.Net.HttpStatusCode.Conflict); //x.Reject(); //x.Reject(1337); x.Resolve(scene); //return scene; }, delay)); }
public static Promise <T> Reject <T>(object reason) { return(PromiseFactory.StartNewDeferred <T>(dfd => { dfd.Reject(reason); })); }
public PromiseEnumerator(PromiseFactory factory, IEnumerator <IPromise <T> > items) { this.Factory = factory; _items = items; _index = 0; _itemCache = new List <T>(); }
public PromiseEnumerator(PromiseFactory factory, int index, IList <T> itemCache, IEnumerator <IPromise <T> > items) { this.Factory = factory; _items = items; _index = index; _itemCache = itemCache; }
public BasePromise(PromiseFactory promiseFactory, ITaskFactory factory, ITaskResult task) { this.TaskFactory = factory; this.TaskResult = task; this._waitHandle = null; this.Factory = promiseFactory; }
internal For(PromiseFactory factory, Func <IPromise <ControlValue <T> > > seed, Func <T, IPromise <ControlValue <bool> > > condition, Func <T, IPromise <ControlValue <T> > > iterator) : base(factory) { this._current = default(T); this._seed = seed; this._condition = condition; this._iterator = iterator; }
public static Func <IPromise> ReturnPromise(this Action fn, PromiseFactory factory) { return(() => { fn(); return factory.Value(); }); }
public IntervalHandleImpl(PromiseFactory factory, int timeout, Func <IPromise> action, PromisePriority priority) { var x = new BackboneIntervalHandleImpl <IntervalHandleImpl>(this, factory, timeout, () => action().Then(() => (object)null), priority); x.Start(); _base = x; }
public static Func <T, IPromise> ReturnPromise <T>(this Action <T> fn, PromiseFactory factory) { return(x => { fn(x); return factory.Value(); }); }
public static IPromise <E> SafeThen <T, E>(this PromiseFactory factory, IPromise <T> next, Func <T, IPromise <E> > consumer) { if (next == null) { return(null); } return(next.Then(result => consumer(result))); }
public static IPromise <T> UnCast <T>(this IPromise p, PromiseFactory factory, T defaultValue) { if (p == null) { return(factory.Value(defaultValue)); } return(p.Then(() => defaultValue)); }
public MergeEnumerator(PromiseFactory factory, NullableResult <Tuple <Key, Value> > current, IComparer <Key> comparer, IPromiseEnumerator <Tuple <Key, Value> > left, IPromiseEnumerator <Tuple <Key, Value> > right) { this._left = left; this._right = right; this.Factory = factory; this._current = current; this._comparer = comparer; }
public BackboneIntervalHandleImpl(Backbone backbone, PromiseFactory factory, int timeout, Func <IPromise <object> > action, PromisePriority priority) { this._backbone = backbone; this._factory = factory; this._timeout = timeout; this._action = action; this._priority = priority; this._canceled = false; this._started = false; }
public Promise Shutdown() { const float delay = 2f; Debug.Log(string.Format("SceneBController.Shutdown - FriendlyName={0}", FriendlyName)); return(PromiseFactory.StartNew(() => { Debug.Log(string.Format("SceneBController.Shutdown - [Then] complete. FriendlyName={0}", FriendlyName)); return "Shutdown"; }, delay)); }
public IntervalHandleImpl(PromiseFactory factory, int timeout, Action action, PromisePriority priority) { var x = new BackboneIntervalHandleImpl <IntervalHandleImpl>(this, factory, timeout, () => { action(); return(factory.Value <object>(null)); }, priority); x.Start(); _base = x; }
public static Func <T, IPromise <ControlValue <E> > > Canonical <T, E>(this PromiseFactory factory, Func <T, IPromise <NullableResult <E> > > fn) { return(factory.Canonical <T, E>(x => factory.SafeThen(fn(x), result => { if (result == null || !result.HasResult) { return ControlValue <E> .Next; } return ControlValue <E> .Return(result.Result); }))); }
public Promise Init() { const float delay = 3f; Debug.Log(string.Format("SceneBController.Init - FriendlyName={0}", FriendlyName)); return(PromiseFactory.StartNew(() => { Debug.Log(string.Format("SceneBController.Init - [Then] complete. FriendlyName={0}", FriendlyName)); return "Init"; }, delay)); }
public void ThenOnPendingPromise() { var promise = PromiseFactory.CreatePending <int>(); var thenAddOne = promise.Then(addOne); Assert.That(thenAddOne.Pending); promise.Fulfill(1); Assert.That(thenAddOne.Pending, Is.False); Assert.That(thenAddOne.Fulfilled, Is.True); Assert.That(thenAddOne.Rejected, Is.False); Assert.That(thenAddOne.Value, Is.EqualTo(2)); }
private static IPromise <IPromiseEnumerator <Tuple <Key, Value> > > OrderByInternal <Key, Value> (PromiseFactory factory, IPromiseEnumerator <Tuple <Key, Value> > items, int count, IComparer <Key> comparer) { if (count < 2) { return(factory.Value(items)); } int at = count / 2; return(OrderByInternal(factory, TakeWhileEnumerator.Create(items, at), at, comparer).Then(firstPart => items.Advance(at).Then(half => OrderByInternal(factory, half, count - at, comparer)).Then(secondPart => (IPromiseEnumerator <Tuple <Key, Value> >) new MergeEnumerator <Key, Value>(factory, new NullableResult <Tuple <Key, Value> >(), comparer, firstPart, secondPart)))); }
public static IPromise <NullableResult <T> > ToNullableResult <T>(this IPromise <ControlValue <T> > p, PromiseFactory factory) { if (p == null) { return(factory.Value(new NullableResult <T>())); } return(p.Then(result => { if (result == null || result.State != ControlState.Return || !result.HasValue) { return new NullableResult <T>(); } return new NullableResult <T>(result.Value); })); }
public static Func <T, IPromise <ControlValue <object> > > Canonical <T>(this PromiseFactory factory, Action <T> fn) { return(factory.Canonical <T>(fn.ReturnPromise(factory))); }
public static IPromise <T> UnCast <T>(this IPromise p, PromiseFactory factory) { return(p.UnCast <T>(factory, default(T))); }
public static IPromise <object> UnCast(this IPromise p, PromiseFactory factory) { return(p.UnCast <object>(factory, null)); }
public ManualPromise(PromiseFactory promiseFactory, ITaskFactory factory) : base(promiseFactory, factory, new ManualTaskResult(factory.ThreadPool)) { }
internal DoWhileNullableResult(PromiseFactory factory, Func <IPromise <ControlValue <T> > > body) : base(factory) { _while = new DoWhileControlValue <T>(factory, body); }
internal DoWhileControlValue(PromiseFactory factory, Func <IPromise <ControlValue <T> > > body) : base(factory) { this._body = body; }
public static IPromise <E> SafeThen <T, E>(this PromiseFactory factory, IPromise <T> next, Func <IPromise <E> > consumer) { return(factory.SafeThen(next, x => consumer())); }
internal DoWhileControlState(PromiseFactory factory, Func <IPromise <ControlValue <object> > > body) : base(factory) { _while = new DoWhileControlValue <object>(factory, body); }
public static IPromise <E> SafeThen <T, E>(this PromiseFactory factory, IPromise <T> next, Func <T, E> conusmer) { return(factory.SafeThen(next, x => factory.Value(conusmer(x)))); }