Mercurial > pub > ImplabNet
comparison Implab/Promise.cs @ 66:790e8a997d30
Refactoring
author | cin |
---|---|
date | Thu, 14 Aug 2014 18:08:09 +0400 |
parents | 653c4e04968b |
children | 1714fd8678ef |
comparison
equal
deleted
inserted
replaced
65:653c4e04968b | 66:790e8a997d30 |
---|---|
97 | 97 |
98 public Promise() { | 98 public Promise() { |
99 m_cancellable = true; | 99 m_cancellable = true; |
100 } | 100 } |
101 | 101 |
102 public Promise(IPromiseBase parent, bool cancellable) { | 102 public Promise(IPromise parent, bool cancellable) { |
103 m_cancellable = cancellable; | 103 m_cancellable = cancellable; |
104 if (parent != null) | 104 if (parent != null) |
105 AddHandler( | 105 AddHandler( |
106 null, | 106 null, |
107 null, | 107 null, |
250 AddHandler(resultHandler, errorHandler, medium.InternalCancel); | 250 AddHandler(resultHandler, errorHandler, medium.InternalCancel); |
251 | 251 |
252 return medium; | 252 return medium; |
253 } | 253 } |
254 | 254 |
255 public IPromiseBase Then(Action success, ErrorHandler error) { | 255 public IPromise Then(Action success, ErrorHandler error) { |
256 return Then(x => success(), error); | 256 return Then(x => success(), error); |
257 } | 257 } |
258 | 258 |
259 public IPromiseBase Then(Action success) { | 259 public IPromise Then(Action success) { |
260 return Then(x => success()); | 260 return Then(x => success()); |
261 } | 261 } |
262 | 262 |
263 /// <summary> | 263 /// <summary> |
264 /// Adds new handlers to this promise. | 264 /// Adds new handlers to this promise. |
680 /// <param name="promises">Коллекция первичных обещаний, которые будут объеденены в одно.</param> | 680 /// <param name="promises">Коллекция первичных обещаний, которые будут объеденены в одно.</param> |
681 /// <returns>Новое обещание, объединяющее в себе переданные.</returns> | 681 /// <returns>Новое обещание, объединяющее в себе переданные.</returns> |
682 /// <remarks> | 682 /// <remarks> |
683 /// Если в коллекции встречаюься <c>null</c>, то они воспринимаются как выполненные обещания. | 683 /// Если в коллекции встречаюься <c>null</c>, то они воспринимаются как выполненные обещания. |
684 /// </remarks> | 684 /// </remarks> |
685 public static IPromiseBase CreateComposite(ICollection<IPromiseBase> promises) { | 685 public static IPromise CreateComposite(ICollection<IPromise> promises) { |
686 if (promises == null) | 686 if (promises == null) |
687 throw new ArgumentNullException(); | 687 throw new ArgumentNullException(); |
688 if (promises.Count == 0) | 688 if (promises.Count == 0) |
689 return Promise<object>.ResultToPromise(null); | 689 return Promise<object>.ResultToPromise(null); |
690 | 690 |
728 return p; | 728 return p; |
729 } | 729 } |
730 | 730 |
731 #region IPromiseBase explicit implementation | 731 #region IPromiseBase explicit implementation |
732 | 732 |
733 IPromiseBase IPromiseBase.Error(ErrorHandler error) { | 733 IPromise IPromise.Error(ErrorHandler error) { |
734 return Error(error); | 734 return Error(error); |
735 } | 735 } |
736 | 736 |
737 IPromiseBase IPromiseBase.Anyway(Action handler) { | 737 IPromise IPromise.Anyway(Action handler) { |
738 return Anyway(handler); | 738 return Anyway(handler); |
739 } | 739 } |
740 | 740 |
741 IPromiseBase IPromiseBase.Finally(Action handler) { | 741 IPromise IPromise.Finally(Action handler) { |
742 return Finally(handler); | 742 return Finally(handler); |
743 } | 743 } |
744 | 744 |
745 IPromiseBase IPromiseBase.Cancelled(Action handler) { | 745 IPromise IPromise.Cancelled(Action handler) { |
746 return Cancelled(handler); | 746 return Cancelled(handler); |
747 } | 747 } |
748 | 748 |
749 void IPromiseBase.Join() { | 749 void IPromise.Join() { |
750 Join(); | 750 Join(); |
751 } | 751 } |
752 | 752 |
753 void IPromiseBase.Join(int timeout) { | 753 void IPromise.Join(int timeout) { |
754 Join(timeout); | 754 Join(timeout); |
755 } | 755 } |
756 | 756 |
757 #endregion | 757 #endregion |
758 | 758 |