##// END OF EJS Templates
DRAFT: refactoring, adding cancelation token
cin -
r143:16f926ee499d v2
parent child
Show More
@@ -0,0 +1,36
1 using System;
2
3 namespace Implab {
4 public interface ICancelationToken {
5 /// <summary>
6 /// Indicates wherther the cancellation was requested.
7 /// </summary>
8 bool IsCancelRequested { get ; }
9
10 /// <summary>
11 /// The reason why the operation should be cancelled.
12 /// </summary>
13 Exception CancelReason { get ; }
14
15 /// <summary>
16 /// Accepts if requested.
17 /// </summary>
18 /// <returns><c>true</c>, if if requested was accepted, <c>false</c> otherwise.</returns>
19 bool AcceptIfRequested();
20
21 /// <summary>
22 /// Sets the token to cancelled state.
23 /// </summary>
24 /// <param name="reason">The reason why the operation was cancelled.</param>
25 void SetCancelled(Exception reason);
26
27 /// <summary>
28 /// Adds the listener for the cancellation request, is the cancellation was requested the <paramref name="handler"/>
29 /// is executed immediatelly.
30 /// </summary>
31 /// <param name="handler">The handler which will be executed if the cancel occurs.</param>
32 void CancellationRequested(Action<Exception> handler);
33
34 }
35 }
36
@@ -1,308 +1,296
1 using System;
1 using System;
2 using Implab.Parallels;
2 using Implab.Parallels;
3 using System.Threading;
3 using System.Threading;
4 using System.Reflection;
4 using System.Reflection;
5
5
6 namespace Implab {
6 namespace Implab {
7 public abstract class AbstractPromise<THandler> {
7 public abstract class AbstractPromise<THandler> {
8
8
9 const int UNRESOLVED_SATE = 0;
9 const int UNRESOLVED_SATE = 0;
10 const int TRANSITIONAL_STATE = 1;
10 const int TRANSITIONAL_STATE = 1;
11 const int SUCCEEDED_STATE = 2;
11 const int SUCCEEDED_STATE = 2;
12 const int REJECTED_STATE = 3;
12 const int REJECTED_STATE = 3;
13 const int CANCELLED_STATE = 4;
13 const int CANCELLED_STATE = 4;
14
14
15 const int RESERVED_HANDLERS_COUNT = 4;
15 const int RESERVED_HANDLERS_COUNT = 4;
16
16
17 int m_state;
17 int m_state;
18 Exception m_error;
18 Exception m_error;
19 int m_handlersCount;
19 int m_handlersCount;
20
20
21 readonly THandler[] m_handlers = new THandler[RESERVED_HANDLERS_COUNT];
21 readonly THandler[] m_handlers = new THandler[RESERVED_HANDLERS_COUNT];
22 MTQueue<THandler> m_extraHandlers;
22 MTQueue<THandler> m_extraHandlers;
23 int m_handlerPointer = -1;
23 int m_handlerPointer = -1;
24 int m_handlersCommited;
24 int m_handlersCommited;
25
25
26 #region state managment
26 #region state managment
27 bool BeginTransit() {
27 bool BeginTransit() {
28 return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE);
28 return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE);
29 }
29 }
30
30
31 void CompleteTransit(int state) {
31 void CompleteTransit(int state) {
32 if (TRANSITIONAL_STATE != Interlocked.CompareExchange(ref m_state, state, TRANSITIONAL_STATE))
32 if (TRANSITIONAL_STATE != Interlocked.CompareExchange(ref m_state, state, TRANSITIONAL_STATE))
33 throw new InvalidOperationException("Can't complete transition when the object isn't in the transitional state");
33 throw new InvalidOperationException("Can't complete transition when the object isn't in the transitional state");
34 }
34 }
35
35
36 void WaitTransition() {
36 void WaitTransition() {
37 while (m_state == TRANSITIONAL_STATE) {
37 while (m_state == TRANSITIONAL_STATE) {
38 Thread.MemoryBarrier();
38 Thread.MemoryBarrier();
39 }
39 }
40 }
40 }
41
41
42 protected bool BeginSetResult() {
42 protected bool BeginSetResult() {
43 if (!BeginTransit()) {
43 if (!BeginTransit()) {
44 WaitTransition();
44 WaitTransition();
45 if (m_state != CANCELLED_STATE)
45 if (m_state != CANCELLED_STATE)
46 throw new InvalidOperationException("The promise is already resolved");
46 throw new InvalidOperationException("The promise is already resolved");
47 return false;
47 return false;
48 }
48 }
49 return true;
49 return true;
50 }
50 }
51
51
52 protected void EndSetResult() {
52 protected void EndSetResult() {
53 CompleteTransit(SUCCEEDED_STATE);
53 CompleteTransit(SUCCEEDED_STATE);
54 OnSuccess();
54 OnSuccess();
55 }
55 }
56
56
57
57
58
58
59 /// <summary>
59 /// <summary>
60 /// ВыполняСт ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅, сообщая ΠΎΠ± ошибкС
60 /// ВыполняСт ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅, сообщая ΠΎΠ± ошибкС
61 /// </summary>
61 /// </summary>
62 /// <remarks>
62 /// <remarks>
63 /// ΠŸΠΎΡΠΊΠΎΠ»ΡŒΠΊΡƒ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π² ΠΌΠ½ΠΎΠ³ΠΎΠΏΡ‚ΠΎΡ‡Π½ΠΎΠΉ срСдС, ΠΏΡ€ΠΈ Π΅Π³ΠΎ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ сразу нСсколько ΠΏΠΎΡ‚ΠΎΠΊΠΎΠ²
63 /// ΠŸΠΎΡΠΊΠΎΠ»ΡŒΠΊΡƒ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π² ΠΌΠ½ΠΎΠ³ΠΎΠΏΡ‚ΠΎΡ‡Π½ΠΎΠΉ срСдС, ΠΏΡ€ΠΈ Π΅Π³ΠΎ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ сразу нСсколько ΠΏΠΎΡ‚ΠΎΠΊΠΎΠ²
64 /// ΠΌΠΎΠ³Ρƒ Π²Π΅Ρ€Π½ΡƒΡ‚ΡŒ ΠΎΡˆΠΈΠ±ΠΊΡƒ, ΠΏΡ€ΠΈ этом Ρ‚ΠΎΠ»ΡŒΠΊΠΎ пСрвая Π±ΡƒΠ΄Π΅Ρ‚ использована Π² качСствС Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π°, ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅
64 /// ΠΌΠΎΠ³Ρƒ Π²Π΅Ρ€Π½ΡƒΡ‚ΡŒ ΠΎΡˆΠΈΠ±ΠΊΡƒ, ΠΏΡ€ΠΈ этом Ρ‚ΠΎΠ»ΡŒΠΊΠΎ пСрвая Π±ΡƒΠ΄Π΅Ρ‚ использована Π² качСствС Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π°, ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅
65 /// Π±ΡƒΠ΄ΡƒΡ‚ ΠΏΡ€ΠΎΠΈΠ³Π½ΠΎΡ€ΠΈΡ€ΠΎΠ²Π°Π½Ρ‹.
65 /// Π±ΡƒΠ΄ΡƒΡ‚ ΠΏΡ€ΠΎΠΈΠ³Π½ΠΎΡ€ΠΈΡ€ΠΎΠ²Π°Π½Ρ‹.
66 /// </remarks>
66 /// </remarks>
67 /// <param name="error">Π˜ΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ возникшСС ΠΏΡ€ΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ</param>
67 /// <param name="error">Π˜ΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ возникшСС ΠΏΡ€ΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ</param>
68 /// <exception cref="InvalidOperationException">Π”Π°Π½Π½ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ ΡƒΠΆΠ΅ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΎ</exception>
68 /// <exception cref="InvalidOperationException">Π”Π°Π½Π½ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ ΡƒΠΆΠ΅ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΎ</exception>
69 protected void SetError(Exception error) {
69 protected void SetError(Exception error) {
70 if (BeginTransit()) {
70 if (BeginTransit()) {
71 if (error is OperationCanceledException) {
71 if (error is OperationCanceledException) {
72 CompleteTransit(CANCELLED_STATE);
72 CompleteTransit(CANCELLED_STATE);
73 m_error = error.InnerException;
73 m_error = error.InnerException;
74 OnCancelled();
74 OnCancelled();
75 } else {
75 } else {
76 m_error = error is PromiseTransientException ? error.InnerException : error;
76 m_error = error is PromiseTransientException ? error.InnerException : error;
77 CompleteTransit(REJECTED_STATE);
77 CompleteTransit(REJECTED_STATE);
78 OnError();
78 OnError();
79 }
79 }
80 } else {
80 } else {
81 WaitTransition();
81 WaitTransition();
82 if (m_state == SUCCEEDED_STATE)
82 if (m_state == SUCCEEDED_STATE)
83 throw new InvalidOperationException("The promise is already resolved");
83 throw new InvalidOperationException("The promise is already resolved");
84 }
84 }
85 }
85 }
86
86
87 /// <summary>
87 /// <summary>
88 /// ΠžΡ‚ΠΌΠ΅Π½ΡΠ΅Ρ‚ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΡŽ, Ссли это Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ.
88 /// ΠžΡ‚ΠΌΠ΅Π½ΡΠ΅Ρ‚ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΡŽ, Ссли это Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ.
89 /// </summary>
89 /// </summary>
90 /// <remarks>Для опрСдСлСния Π±Ρ‹Π»Π° Π»ΠΈ опСрация ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½Π° слСдуСт ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ свойство <see cref="IsCancelled"/>.</remarks>
90 /// <remarks>Для опрСдСлСния Π±Ρ‹Π»Π° Π»ΠΈ опСрация ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½Π° слСдуСт ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ свойство <see cref="IsCancelled"/>.</remarks>
91 protected void SetCancelled(Exception reason) {
91 protected void SetCancelled(Exception reason) {
92 if (BeginTransit()) {
92 if (BeginTransit()) {
93 m_error = reason;
93 m_error = reason;
94 CompleteTransit(CANCELLED_STATE);
94 CompleteTransit(CANCELLED_STATE);
95 OnCancelled();
95 OnCancelled();
96 }
96 }
97 }
97 }
98
98
99 protected abstract void SignalSuccess(THandler handler);
99 protected abstract void SignalSuccess(THandler handler);
100
100
101 protected abstract void SignalError(THandler handler, Exception error);
101 protected abstract void SignalError(THandler handler, Exception error);
102
102
103 protected abstract void SignalCancelled(THandler handler, Exception reason);
103 protected abstract void SignalCancelled(THandler handler, Exception reason);
104
104
105 void OnSuccess() {
105 void OnSuccess() {
106 var hp = m_handlerPointer;
106 var hp = m_handlerPointer;
107 var slot = hp +1 ;
107 var slot = hp +1 ;
108 while (slot < m_handlersCommited) {
108 while (slot < m_handlersCommited) {
109 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
109 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
110 SignalSuccess(m_handlers[slot]);
110 SignalSuccess(m_handlers[slot]);
111 }
111 }
112 hp = m_handlerPointer;
112 hp = m_handlerPointer;
113 slot = hp +1 ;
113 slot = hp +1 ;
114 }
114 }
115
115
116
116
117 if (m_extraHandlers != null) {
117 if (m_extraHandlers != null) {
118 THandler handler;
118 THandler handler;
119 while (m_extraHandlers.TryDequeue(out handler))
119 while (m_extraHandlers.TryDequeue(out handler))
120 SignalSuccess(handler);
120 SignalSuccess(handler);
121 }
121 }
122 }
122 }
123
123
124 void OnError() {
124 void OnError() {
125 var hp = m_handlerPointer;
125 var hp = m_handlerPointer;
126 var slot = hp +1 ;
126 var slot = hp +1 ;
127 while (slot < m_handlersCommited) {
127 while (slot < m_handlersCommited) {
128 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
128 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
129 SignalError(m_handlers[slot],m_error);
129 SignalError(m_handlers[slot],m_error);
130 }
130 }
131 hp = m_handlerPointer;
131 hp = m_handlerPointer;
132 slot = hp +1 ;
132 slot = hp +1 ;
133 }
133 }
134
134
135 if (m_extraHandlers != null) {
135 if (m_extraHandlers != null) {
136 THandler handler;
136 THandler handler;
137 while (m_extraHandlers.TryDequeue(out handler))
137 while (m_extraHandlers.TryDequeue(out handler))
138 SignalError(handler, m_error);
138 SignalError(handler, m_error);
139 }
139 }
140 }
140 }
141
141
142 void OnCancelled() {
142 void OnCancelled() {
143 var hp = m_handlerPointer;
143 var hp = m_handlerPointer;
144 var slot = hp +1 ;
144 var slot = hp +1 ;
145 while (slot < m_handlersCommited) {
145 while (slot < m_handlersCommited) {
146 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
146 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) == hp) {
147 SignalCancelled(m_handlers[slot], m_error);
147 SignalCancelled(m_handlers[slot], m_error);
148 }
148 }
149 hp = m_handlerPointer;
149 hp = m_handlerPointer;
150 slot = hp +1 ;
150 slot = hp +1 ;
151 }
151 }
152
152
153 if (m_extraHandlers != null) {
153 if (m_extraHandlers != null) {
154 THandler handler;
154 THandler handler;
155 while (m_extraHandlers.TryDequeue(out handler))
155 while (m_extraHandlers.TryDequeue(out handler))
156 SignalCancelled(handler, m_error);
156 SignalCancelled(handler, m_error);
157 }
157 }
158 }
158 }
159
159
160 #endregion
160 #endregion
161
161
162 protected abstract void Listen(PromiseEventType events, Action handler);
162 protected abstract void Listen(PromiseEventType events, Action handler);
163
163
164 #region synchronization traits
164 #region synchronization traits
165 protected void WaitResult(int timeout) {
165 protected void WaitResult(int timeout) {
166 if (!IsResolved) {
166 if (!IsResolved) {
167 var lk = new object();
167 var lk = new object();
168
168
169 Listen(PromiseEventType.All, () => {
169 Listen(PromiseEventType.All, () => {
170 lock(lk) {
170 lock(lk) {
171 Monitor.Pulse(lk);
171 Monitor.Pulse(lk);
172 }
172 }
173 });
173 });
174
174
175 lock (lk) {
175 lock (lk) {
176 while(!IsResolved) {
176 while(!IsResolved) {
177 if(!Monitor.Wait(lk,timeout))
177 if(!Monitor.Wait(lk,timeout))
178 throw new TimeoutException();
178 throw new TimeoutException();
179 }
179 }
180 }
180 }
181
181
182 }
182 }
183 switch (m_state) {
183 switch (m_state) {
184 case SUCCEEDED_STATE:
184 case SUCCEEDED_STATE:
185 return;
185 return;
186 case CANCELLED_STATE:
186 case CANCELLED_STATE:
187 throw new OperationCanceledException();
187 throw new OperationCanceledException();
188 case REJECTED_STATE:
188 case REJECTED_STATE:
189 throw new TargetInvocationException(m_error);
189 throw new TargetInvocationException(m_error);
190 default:
190 default:
191 throw new ApplicationException(String.Format("Invalid promise state {0}", m_state));
191 throw new ApplicationException(String.Format("Invalid promise state {0}", m_state));
192 }
192 }
193 }
193 }
194 #endregion
194 #endregion
195
195
196 #region handlers managment
196 #region handlers managment
197
197
198 protected void AddHandler(THandler handler) {
198 protected void AddHandler(THandler handler) {
199
199
200 if (m_state > 1) {
200 if (m_state > 1) {
201 // the promise is in the resolved state, just invoke the handler
201 // the promise is in the resolved state, just invoke the handler
202 InvokeHandler(handler);
202 InvokeHandler(handler);
203 } else {
203 } else {
204 var slot = Interlocked.Increment(ref m_handlersCount) - 1;
204 var slot = Interlocked.Increment(ref m_handlersCount) - 1;
205
205
206 if (slot < RESERVED_HANDLERS_COUNT) {
206 if (slot < RESERVED_HANDLERS_COUNT) {
207 m_handlers[slot] = handler;
207 m_handlers[slot] = handler;
208
208
209 while (slot != Interlocked.CompareExchange(ref m_handlersCommited, slot + 1, slot)) {
209 while (slot != Interlocked.CompareExchange(ref m_handlersCommited, slot + 1, slot)) {
210 }
210 }
211
211
212 if (m_state > 1) {
212 if (m_state > 1) {
213 do {
213 do {
214 var hp = m_handlerPointer;
214 var hp = m_handlerPointer;
215 slot = hp + 1;
215 slot = hp + 1;
216 if (slot < m_handlersCommited) {
216 if (slot < m_handlersCommited) {
217 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) != hp)
217 if (Interlocked.CompareExchange(ref m_handlerPointer, slot, hp) != hp)
218 continue;
218 continue;
219 InvokeHandler(m_handlers[slot]);
219 InvokeHandler(m_handlers[slot]);
220 }
220 }
221 break;
221 break;
222 } while(true);
222 } while(true);
223 }
223 }
224 } else {
224 } else {
225 if (slot == RESERVED_HANDLERS_COUNT) {
225 if (slot == RESERVED_HANDLERS_COUNT) {
226 m_extraHandlers = new MTQueue<THandler>();
226 m_extraHandlers = new MTQueue<THandler>();
227 } else {
227 } else {
228 while (m_extraHandlers == null)
228 while (m_extraHandlers == null)
229 Thread.MemoryBarrier();
229 Thread.MemoryBarrier();
230 }
230 }
231
231
232 m_extraHandlers.Enqueue(handler);
232 m_extraHandlers.Enqueue(handler);
233
233
234 if (m_state > 1 && m_extraHandlers.TryDequeue(out handler))
234 if (m_state > 1 && m_extraHandlers.TryDequeue(out handler))
235 // if the promise have been resolved while we was adding the handler to the queue
235 // if the promise have been resolved while we was adding the handler to the queue
236 // we can't guarantee that someone is still processing it
236 // we can't guarantee that someone is still processing it
237 // therefore we need to fetch a handler from the queue and execute it
237 // therefore we need to fetch a handler from the queue and execute it
238 // note that fetched handler may be not the one that we have added
238 // note that fetched handler may be not the one that we have added
239 // even we can fetch no handlers at all :)
239 // even we can fetch no handlers at all :)
240 InvokeHandler(handler);
240 InvokeHandler(handler);
241 }
241 }
242 }
242 }
243 }
243 }
244
244
245 protected void InvokeHandler(THandler handler) {
245 protected void InvokeHandler(THandler handler) {
246 switch (m_state) {
246 switch (m_state) {
247 case SUCCEEDED_STATE:
247 case SUCCEEDED_STATE:
248 SignalSuccess(handler);
248 SignalSuccess(handler);
249 break;
249 break;
250 case CANCELLED_STATE:
250 case CANCELLED_STATE:
251 SignalCancelled(handler, m_error);
251 SignalCancelled(handler, m_error);
252 break;
252 break;
253 case REJECTED_STATE:
253 case REJECTED_STATE:
254 SignalError(handler, m_error);
254 SignalError(handler, m_error);
255 break;
255 break;
256 default:
256 default:
257 throw new Exception(String.Format("Invalid promise state {0}", m_state));
257 throw new Exception(String.Format("Invalid promise state {0}", m_state));
258 }
258 }
259 }
259 }
260
260
261 #endregion
261 #endregion
262
262
263 #region IPromise implementation
263 #region IPromise implementation
264
264
265 public void Join(int timeout) {
265 public void Join(int timeout) {
266 WaitResult(timeout);
266 WaitResult(timeout);
267 }
267 }
268
268
269 public void Join() {
269 public void Join() {
270 WaitResult(-1);
270 WaitResult(-1);
271 }
271 }
272
272
273 public bool IsResolved {
273 public bool IsResolved {
274 get {
274 get {
275 Thread.MemoryBarrier();
275 Thread.MemoryBarrier();
276 return m_state > 1;
276 return m_state > 1;
277 }
277 }
278 }
278 }
279
279
280 public bool IsCancelled {
280 public bool IsCancelled {
281 get {
281 get {
282 Thread.MemoryBarrier();
282 Thread.MemoryBarrier();
283 return m_state == CANCELLED_STATE;
283 return m_state == CANCELLED_STATE;
284 }
284 }
285 }
285 }
286
286
287 #endregion
287 #endregion
288
288
289 #region ICancellable implementation
290
291 public void Cancel() {
292 SetCancelled(null);
293 }
294
295 public void Cancel(Exception reason) {
296 SetCancelled(reason);
297 }
298
299 #endregion
300
301 public Exception Error {
289 public Exception Error {
302 get {
290 get {
303 return m_error;
291 return m_error;
304 }
292 }
305 }
293 }
306 }
294 }
307 }
295 }
308
296
@@ -1,24 +1,24
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 /// <summary>
4 /// <summary>
5 /// Deferred result, usually used by asynchronous services as the service part of the promise.
5 /// Deferred result, usually used by asynchronous services as the service part of the promise.
6 /// </summary>
6 /// </summary>
7 public interface IDeferred : ICancellable {
7 public interface IDeferred : ICancelationToken {
8
8
9 void Resolve();
9 void Resolve();
10
10
11 /// <summary>
11 /// <summary>
12 /// Reject the promise with the specified error.
12 /// Reject the promise with the specified error.
13 /// </summary>
13 /// </summary>
14 /// <param name="error">The reason why the promise is rejected.</param>
14 /// <param name="error">The reason why the promise is rejected.</param>
15 /// <remarks>
15 /// <remarks>
16 /// Some exceptions are treated in a special case:
16 /// Some exceptions are treated in a special case:
17 /// <see cref="OperationCanceledException"/> is interpreted as call to <see cref="Cancel()"/> method,
17 /// <see cref="OperationCanceledException"/> is interpreted as call to <see cref="Cancel()"/> method,
18 /// and <see cref="PromiseTransientException"/> is always unwrapped and its
18 /// and <see cref="PromiseTransientException"/> is always unwrapped and its
19 /// <see cref="PromiseTransientException.InnerException"> is used as the reason to reject promise.
19 /// <see cref="PromiseTransientException.InnerException"> is used as the reason to reject promise.
20 /// </remarks>
20 /// </remarks>
21 void Reject(Exception error);
21 void Reject(Exception error);
22 }
22 }
23 }
23 }
24
24
@@ -1,10 +1,10
1 using System;
1 using System;
2
2
3 namespace Implab {
3 namespace Implab {
4 public interface IDeferred<T> : ICancellable {
4 public interface IDeferred<T> : ICancelationToken {
5 void Resolve(T value);
5 void Resolve(T value);
6
6
7 void Reject(Exception error);
7 void Reject(Exception error);
8 }
8 }
9 }
9 }
10
10
@@ -1,231 +1,234
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
7 <OutputType>Library</OutputType>
7 <OutputType>Library</OutputType>
8 <RootNamespace>Implab</RootNamespace>
8 <RootNamespace>Implab</RootNamespace>
9 <AssemblyName>Implab</AssemblyName>
9 <AssemblyName>Implab</AssemblyName>
10 <ProductVersion>8.0.30703</ProductVersion>
11 <SchemaVersion>2.0</SchemaVersion>
10 </PropertyGroup>
12 </PropertyGroup>
11 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12 <DebugSymbols>true</DebugSymbols>
14 <DebugSymbols>true</DebugSymbols>
13 <DebugType>full</DebugType>
15 <DebugType>full</DebugType>
14 <Optimize>false</Optimize>
16 <Optimize>false</Optimize>
15 <OutputPath>bin\Debug</OutputPath>
17 <OutputPath>bin\Debug</OutputPath>
16 <DefineConstants>TRACE;DEBUG;</DefineConstants>
18 <DefineConstants>TRACE;DEBUG;</DefineConstants>
17 <ErrorReport>prompt</ErrorReport>
19 <ErrorReport>prompt</ErrorReport>
18 <WarningLevel>4</WarningLevel>
20 <WarningLevel>4</WarningLevel>
19 <ConsolePause>false</ConsolePause>
21 <ConsolePause>false</ConsolePause>
20 <RunCodeAnalysis>true</RunCodeAnalysis>
22 <RunCodeAnalysis>true</RunCodeAnalysis>
21 </PropertyGroup>
23 </PropertyGroup>
22 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23 <DebugType>full</DebugType>
25 <DebugType>full</DebugType>
24 <Optimize>true</Optimize>
26 <Optimize>true</Optimize>
25 <OutputPath>bin\Release</OutputPath>
27 <OutputPath>bin\Release</OutputPath>
26 <ErrorReport>prompt</ErrorReport>
28 <ErrorReport>prompt</ErrorReport>
27 <WarningLevel>4</WarningLevel>
29 <WarningLevel>4</WarningLevel>
28 <ConsolePause>false</ConsolePause>
30 <ConsolePause>false</ConsolePause>
29 </PropertyGroup>
31 </PropertyGroup>
30 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
32 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
31 <DebugSymbols>true</DebugSymbols>
33 <DebugSymbols>true</DebugSymbols>
32 <DebugType>full</DebugType>
34 <DebugType>full</DebugType>
33 <Optimize>false</Optimize>
35 <Optimize>false</Optimize>
34 <OutputPath>bin\Debug</OutputPath>
36 <OutputPath>bin\Debug</OutputPath>
35 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
37 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
36 <ErrorReport>prompt</ErrorReport>
38 <ErrorReport>prompt</ErrorReport>
37 <WarningLevel>4</WarningLevel>
39 <WarningLevel>4</WarningLevel>
38 <RunCodeAnalysis>true</RunCodeAnalysis>
40 <RunCodeAnalysis>true</RunCodeAnalysis>
39 <ConsolePause>false</ConsolePause>
41 <ConsolePause>false</ConsolePause>
40 </PropertyGroup>
42 </PropertyGroup>
41 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
42 <Optimize>true</Optimize>
44 <Optimize>true</Optimize>
43 <OutputPath>bin\Release</OutputPath>
45 <OutputPath>bin\Release</OutputPath>
44 <ErrorReport>prompt</ErrorReport>
46 <ErrorReport>prompt</ErrorReport>
45 <WarningLevel>4</WarningLevel>
47 <WarningLevel>4</WarningLevel>
46 <ConsolePause>false</ConsolePause>
48 <ConsolePause>false</ConsolePause>
47 <DefineConstants>NET_4_5</DefineConstants>
49 <DefineConstants>NET_4_5</DefineConstants>
48 </PropertyGroup>
50 </PropertyGroup>
49 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
51 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
50 <DebugSymbols>true</DebugSymbols>
52 <DebugSymbols>true</DebugSymbols>
51 <DebugType>full</DebugType>
53 <DebugType>full</DebugType>
52 <Optimize>false</Optimize>
54 <Optimize>false</Optimize>
53 <OutputPath>bin\Debug</OutputPath>
55 <OutputPath>bin\Debug</OutputPath>
54 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
56 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
55 <ErrorReport>prompt</ErrorReport>
57 <ErrorReport>prompt</ErrorReport>
56 <WarningLevel>4</WarningLevel>
58 <WarningLevel>4</WarningLevel>
57 <RunCodeAnalysis>true</RunCodeAnalysis>
59 <RunCodeAnalysis>true</RunCodeAnalysis>
58 <ConsolePause>false</ConsolePause>
60 <ConsolePause>false</ConsolePause>
59 </PropertyGroup>
61 </PropertyGroup>
60 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
62 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
61 <Optimize>true</Optimize>
63 <Optimize>true</Optimize>
62 <OutputPath>bin\Release</OutputPath>
64 <OutputPath>bin\Release</OutputPath>
63 <DefineConstants>NET_4_5;MONO;</DefineConstants>
65 <DefineConstants>NET_4_5;MONO;</DefineConstants>
64 <ErrorReport>prompt</ErrorReport>
66 <ErrorReport>prompt</ErrorReport>
65 <WarningLevel>4</WarningLevel>
67 <WarningLevel>4</WarningLevel>
66 <ConsolePause>false</ConsolePause>
68 <ConsolePause>false</ConsolePause>
67 </PropertyGroup>
69 </PropertyGroup>
68 <ItemGroup>
70 <ItemGroup>
69 <Reference Include="System" />
71 <Reference Include="System" />
70 <Reference Include="System.Xml" />
72 <Reference Include="System.Xml" />
71 </ItemGroup>
73 </ItemGroup>
72 <ItemGroup>
74 <ItemGroup>
73 <Compile Include="Component.cs" />
75 <Compile Include="Component.cs" />
74 <Compile Include="CustomEqualityComparer.cs" />
76 <Compile Include="CustomEqualityComparer.cs" />
75 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
77 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
76 <Compile Include="Diagnostics\EventText.cs" />
78 <Compile Include="Diagnostics\EventText.cs" />
77 <Compile Include="Diagnostics\LogChannel.cs" />
79 <Compile Include="Diagnostics\LogChannel.cs" />
78 <Compile Include="Diagnostics\LogicalOperation.cs" />
80 <Compile Include="Diagnostics\LogicalOperation.cs" />
79 <Compile Include="Diagnostics\TextFileListener.cs" />
81 <Compile Include="Diagnostics\TextFileListener.cs" />
80 <Compile Include="Diagnostics\TraceLog.cs" />
82 <Compile Include="Diagnostics\TraceLog.cs" />
81 <Compile Include="Diagnostics\TraceEvent.cs" />
83 <Compile Include="Diagnostics\TraceEvent.cs" />
82 <Compile Include="Diagnostics\TraceEventType.cs" />
84 <Compile Include="Diagnostics\TraceEventType.cs" />
83 <Compile Include="Disposable.cs" />
85 <Compile Include="Disposable.cs" />
84 <Compile Include="ICancellable.cs" />
86 <Compile Include="ICancellable.cs" />
85 <Compile Include="IProgressHandler.cs" />
87 <Compile Include="IProgressHandler.cs" />
86 <Compile Include="IProgressNotifier.cs" />
88 <Compile Include="IProgressNotifier.cs" />
87 <Compile Include="IPromiseT.cs" />
89 <Compile Include="IPromiseT.cs" />
88 <Compile Include="IPromise.cs" />
90 <Compile Include="IPromise.cs" />
89 <Compile Include="IServiceLocator.cs" />
91 <Compile Include="IServiceLocator.cs" />
90 <Compile Include="ITaskController.cs" />
92 <Compile Include="ITaskController.cs" />
91 <Compile Include="JSON\JSONElementContext.cs" />
93 <Compile Include="JSON\JSONElementContext.cs" />
92 <Compile Include="JSON\JSONElementType.cs" />
94 <Compile Include="JSON\JSONElementType.cs" />
93 <Compile Include="JSON\JSONGrammar.cs" />
95 <Compile Include="JSON\JSONGrammar.cs" />
94 <Compile Include="JSON\JSONParser.cs" />
96 <Compile Include="JSON\JSONParser.cs" />
95 <Compile Include="JSON\JSONScanner.cs" />
97 <Compile Include="JSON\JSONScanner.cs" />
96 <Compile Include="JSON\JsonTokenType.cs" />
98 <Compile Include="JSON\JsonTokenType.cs" />
97 <Compile Include="JSON\JSONWriter.cs" />
99 <Compile Include="JSON\JSONWriter.cs" />
98 <Compile Include="JSON\JSONXmlReader.cs" />
100 <Compile Include="JSON\JSONXmlReader.cs" />
99 <Compile Include="JSON\JSONXmlReaderOptions.cs" />
101 <Compile Include="JSON\JSONXmlReaderOptions.cs" />
100 <Compile Include="JSON\StringTranslator.cs" />
102 <Compile Include="JSON\StringTranslator.cs" />
101 <Compile Include="Parallels\DispatchPool.cs" />
103 <Compile Include="Parallels\DispatchPool.cs" />
102 <Compile Include="Parallels\ArrayTraits.cs" />
104 <Compile Include="Parallels\ArrayTraits.cs" />
103 <Compile Include="Parallels\MTQueue.cs" />
105 <Compile Include="Parallels\MTQueue.cs" />
104 <Compile Include="Parallels\WorkerPool.cs" />
106 <Compile Include="Parallels\WorkerPool.cs" />
105 <Compile Include="Parsing\Alphabet.cs" />
107 <Compile Include="Parsing\Alphabet.cs" />
106 <Compile Include="Parsing\AlphabetBase.cs" />
108 <Compile Include="Parsing\AlphabetBase.cs" />
107 <Compile Include="Parsing\AltToken.cs" />
109 <Compile Include="Parsing\AltToken.cs" />
108 <Compile Include="Parsing\BinaryToken.cs" />
110 <Compile Include="Parsing\BinaryToken.cs" />
109 <Compile Include="Parsing\CatToken.cs" />
111 <Compile Include="Parsing\CatToken.cs" />
110 <Compile Include="Parsing\CDFADefinition.cs" />
112 <Compile Include="Parsing\CDFADefinition.cs" />
111 <Compile Include="Parsing\DFABuilder.cs" />
113 <Compile Include="Parsing\DFABuilder.cs" />
112 <Compile Include="Parsing\DFADefinitionBase.cs" />
114 <Compile Include="Parsing\DFADefinitionBase.cs" />
113 <Compile Include="Parsing\DFAStateDescriptor.cs" />
115 <Compile Include="Parsing\DFAStateDescriptor.cs" />
114 <Compile Include="Parsing\DFAutomaton.cs" />
116 <Compile Include="Parsing\DFAutomaton.cs" />
115 <Compile Include="Parsing\EDFADefinition.cs" />
117 <Compile Include="Parsing\EDFADefinition.cs" />
116 <Compile Include="Parsing\EmptyToken.cs" />
118 <Compile Include="Parsing\EmptyToken.cs" />
117 <Compile Include="Parsing\EndToken.cs" />
119 <Compile Include="Parsing\EndToken.cs" />
118 <Compile Include="Parsing\EnumAlphabet.cs" />
120 <Compile Include="Parsing\EnumAlphabet.cs" />
119 <Compile Include="Parsing\Grammar.cs" />
121 <Compile Include="Parsing\Grammar.cs" />
120 <Compile Include="Parsing\IAlphabet.cs" />
122 <Compile Include="Parsing\IAlphabet.cs" />
121 <Compile Include="Parsing\IDFADefinition.cs" />
123 <Compile Include="Parsing\IDFADefinition.cs" />
122 <Compile Include="Parsing\IVisitor.cs" />
124 <Compile Include="Parsing\IVisitor.cs" />
123 <Compile Include="Parsing\ParserException.cs" />
125 <Compile Include="Parsing\ParserException.cs" />
124 <Compile Include="Parsing\Scanner.cs" />
126 <Compile Include="Parsing\Scanner.cs" />
125 <Compile Include="Parsing\StarToken.cs" />
127 <Compile Include="Parsing\StarToken.cs" />
126 <Compile Include="Parsing\SymbolToken.cs" />
128 <Compile Include="Parsing\SymbolToken.cs" />
127 <Compile Include="Parsing\Token.cs" />
129 <Compile Include="Parsing\Token.cs" />
128 <Compile Include="ServiceLocator.cs" />
130 <Compile Include="ServiceLocator.cs" />
129 <Compile Include="TaskController.cs" />
131 <Compile Include="TaskController.cs" />
130 <Compile Include="ProgressInitEventArgs.cs" />
132 <Compile Include="ProgressInitEventArgs.cs" />
131 <Compile Include="Properties\AssemblyInfo.cs" />
133 <Compile Include="Properties\AssemblyInfo.cs" />
132 <Compile Include="Parallels\AsyncPool.cs" />
134 <Compile Include="Parallels\AsyncPool.cs" />
133 <Compile Include="Safe.cs" />
135 <Compile Include="Safe.cs" />
134 <Compile Include="ValueEventArgs.cs" />
136 <Compile Include="ValueEventArgs.cs" />
135 <Compile Include="PromiseExtensions.cs" />
137 <Compile Include="PromiseExtensions.cs" />
136 <Compile Include="SyncContextPromise.cs" />
138 <Compile Include="SyncContextPromise.cs" />
137 <Compile Include="Diagnostics\OperationContext.cs" />
139 <Compile Include="Diagnostics\OperationContext.cs" />
138 <Compile Include="Diagnostics\TraceContext.cs" />
140 <Compile Include="Diagnostics\TraceContext.cs" />
139 <Compile Include="Diagnostics\LogEventArgs.cs" />
141 <Compile Include="Diagnostics\LogEventArgs.cs" />
140 <Compile Include="Diagnostics\LogEventArgsT.cs" />
142 <Compile Include="Diagnostics\LogEventArgsT.cs" />
141 <Compile Include="Diagnostics\Extensions.cs" />
143 <Compile Include="Diagnostics\Extensions.cs" />
142 <Compile Include="IComponentContainer.cs" />
144 <Compile Include="IComponentContainer.cs" />
143 <Compile Include="PromiseEventType.cs" />
145 <Compile Include="PromiseEventType.cs" />
144 <Compile Include="ComponentContainer.cs" />
146 <Compile Include="ComponentContainer.cs" />
145 <Compile Include="DisposablePool.cs" />
147 <Compile Include="DisposablePool.cs" />
146 <Compile Include="ObjectPool.cs" />
148 <Compile Include="ObjectPool.cs" />
147 <Compile Include="Parallels\AsyncQueue.cs" />
149 <Compile Include="Parallels\AsyncQueue.cs" />
148 <Compile Include="PromiseT.cs" />
150 <Compile Include="PromiseT.cs" />
149 <Compile Include="IDeferred.cs" />
151 <Compile Include="IDeferred.cs" />
150 <Compile Include="IDeferredT.cs" />
152 <Compile Include="IDeferredT.cs" />
151 <Compile Include="AbstractPromise.cs" />
153 <Compile Include="AbstractPromise.cs" />
152 <Compile Include="Promise.cs" />
154 <Compile Include="Promise.cs" />
153 <Compile Include="PromiseTransientException.cs" />
155 <Compile Include="PromiseTransientException.cs" />
154 <Compile Include="Parallels\Signal.cs" />
156 <Compile Include="Parallels\Signal.cs" />
155 <Compile Include="Parallels\SharedLock.cs" />
157 <Compile Include="Parallels\SharedLock.cs" />
156 <Compile Include="Diagnostics\ILogWriter.cs" />
158 <Compile Include="Diagnostics\ILogWriter.cs" />
157 <Compile Include="Diagnostics\ListenerBase.cs" />
159 <Compile Include="Diagnostics\ListenerBase.cs" />
158 <Compile Include="Parallels\BlockingQueue.cs" />
160 <Compile Include="Parallels\BlockingQueue.cs" />
161 <Compile Include="ICancelationToken.cs" />
159 </ItemGroup>
162 </ItemGroup>
160 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
163 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
161 <ItemGroup />
164 <ItemGroup />
162 <ProjectExtensions>
165 <ProjectExtensions>
163 <MonoDevelop>
166 <MonoDevelop>
164 <Properties>
167 <Properties>
165 <Policies>
168 <Policies>
166 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
169 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
167 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
170 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
168 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
171 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
169 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
172 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
170 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
173 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
171 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
174 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
172 <NameConventionPolicy>
175 <NameConventionPolicy>
173 <Rules>
176 <Rules>
174 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
177 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
175 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
178 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
176 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
179 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
177 <RequiredPrefixes>
180 <RequiredPrefixes>
178 <String>I</String>
181 <String>I</String>
179 </RequiredPrefixes>
182 </RequiredPrefixes>
180 </NamingRule>
183 </NamingRule>
181 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
184 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
182 <RequiredSuffixes>
185 <RequiredSuffixes>
183 <String>Attribute</String>
186 <String>Attribute</String>
184 </RequiredSuffixes>
187 </RequiredSuffixes>
185 </NamingRule>
188 </NamingRule>
186 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
189 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
187 <RequiredSuffixes>
190 <RequiredSuffixes>
188 <String>EventArgs</String>
191 <String>EventArgs</String>
189 </RequiredSuffixes>
192 </RequiredSuffixes>
190 </NamingRule>
193 </NamingRule>
191 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
194 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
192 <RequiredSuffixes>
195 <RequiredSuffixes>
193 <String>Exception</String>
196 <String>Exception</String>
194 </RequiredSuffixes>
197 </RequiredSuffixes>
195 </NamingRule>
198 </NamingRule>
196 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
199 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
197 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
200 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
198 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
201 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
199 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
202 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
200 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
203 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
201 <RequiredPrefixes>
204 <RequiredPrefixes>
202 <String>m_</String>
205 <String>m_</String>
203 </RequiredPrefixes>
206 </RequiredPrefixes>
204 </NamingRule>
207 </NamingRule>
205 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
208 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
206 <RequiredPrefixes>
209 <RequiredPrefixes>
207 <String>_</String>
210 <String>_</String>
208 </RequiredPrefixes>
211 </RequiredPrefixes>
209 </NamingRule>
212 </NamingRule>
210 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
213 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
211 <RequiredPrefixes>
214 <RequiredPrefixes>
212 <String>m_</String>
215 <String>m_</String>
213 </RequiredPrefixes>
216 </RequiredPrefixes>
214 </NamingRule>
217 </NamingRule>
215 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
218 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
216 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
219 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
217 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
220 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
218 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
221 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
219 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
222 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
220 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
223 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
221 <RequiredPrefixes>
224 <RequiredPrefixes>
222 <String>T</String>
225 <String>T</String>
223 </RequiredPrefixes>
226 </RequiredPrefixes>
224 </NamingRule>
227 </NamingRule>
225 </Rules>
228 </Rules>
226 </NameConventionPolicy>
229 </NameConventionPolicy>
227 </Policies>
230 </Policies>
228 </Properties>
231 </Properties>
229 </MonoDevelop>
232 </MonoDevelop>
230 </ProjectExtensions>
233 </ProjectExtensions>
231 </Project> No newline at end of file
234 </Project>
General Comments 0
You need to be logged in to leave comments. Login now