Mercurial > pub > ImplabNet
annotate Implab/SuccessPromise.cs @ 210:5dc21f6a3222 v2
Code review for RunnableComponent
Added StaApartment class based on System.Windows.Forms.Application message loop
author | cin |
---|---|
date | Mon, 20 Mar 2017 17:44:18 +0300 |
parents | 4d9830a9bbb8 |
children | cbe10ac0731e |
rev | line source |
---|---|
145 | 1 using System; |
2 | |
3 namespace Implab { | |
4 public class SuccessPromise : IPromise { | |
5 #region IPromise implementation | |
6 | |
7 public IPromise On(Action success, Action<Exception> error, Action<Exception> cancel) { | |
8 if (success != null) { | |
9 try { | |
10 success(); | |
203
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
145
diff
changeset
|
11 // Analysis disable once EmptyGeneralCatchClause |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
145
diff
changeset
|
12 } catch { |
145 | 13 } |
14 } | |
15 return this; | |
16 } | |
17 | |
18 public IPromise On(Action success, Action<Exception> error) { | |
19 if (success != null) { | |
20 try { | |
21 success(); | |
203
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
145
diff
changeset
|
22 // Analysis disable once EmptyGeneralCatchClause |
4d9830a9bbb8
Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
145
diff
changeset
|
23 } catch { |
145 | 24 } |
25 } | |
26 return this; | |
27 } | |
28 | |
29 public IPromise On(Action success) { | |
30 if (success != null) { | |
31 try { | |
32 success(); | |
33 // Analysis disable once EmptyGeneralCatchClause | |
34 } catch { | |
35 } | |
36 } | |
37 return this; | |
38 } | |
39 | |
40 public IPromise On(Action handler, PromiseEventType events) { | |
41 if (handler != null && events.HasFlag(PromiseEventType.Success)) { | |
42 try { | |
43 handler(); | |
44 // Analysis disable once EmptyGeneralCatchClause | |
45 } catch { | |
46 } | |
47 } | |
48 return this; | |
49 } | |
50 | |
51 public IPromise<T> Cast<T>() { | |
52 throw new InvalidCastException(); | |
53 } | |
54 | |
55 public void Join() { | |
56 } | |
57 | |
58 public void Join(int timeout) { | |
59 } | |
60 | |
61 public Type PromiseType { | |
62 get { | |
63 return typeof(void); | |
64 } | |
65 } | |
66 | |
67 public bool IsResolved { | |
68 get { | |
69 return true; | |
70 } | |
71 } | |
72 | |
73 public bool IsCancelled { | |
74 get { | |
75 return false; | |
76 } | |
77 } | |
78 | |
79 public Exception Error { | |
80 get { | |
81 return null; | |
82 } | |
83 } | |
84 | |
85 #endregion | |
86 | |
87 #region ICancellable implementation | |
88 | |
89 public void Cancel() { | |
90 } | |
91 | |
92 public void Cancel(Exception reason) { | |
93 } | |
94 | |
95 #endregion | |
96 | |
97 } | |
98 } | |
99 |