|
@@
-191,7
+191,7
namespace Implab {
|
|
191
|
/// This handler will recieve an operation result as a parameter.</param>
|
|
191
|
/// This handler will recieve an operation result as a parameter.</param>
|
|
192
|
/// <param name="error">Handles an exception that may occur during the operation.</param>
|
|
192
|
/// <param name="error">Handles an exception that may occur during the operation.</param>
|
|
193
|
/// <returns>The new promise chained to this one.</returns>
|
|
193
|
/// <returns>The new promise chained to this one.</returns>
|
|
194
|
public Promise<T> Then(ResultHandler<T> success, ErrorHandler error) {
|
|
194
|
public IPromise<T> Then(ResultHandler<T> success, ErrorHandler error) {
|
|
195
|
if (success == null && error == null)
|
|
195
|
if (success == null && error == null)
|
|
196
|
return this;
|
|
196
|
return this;
|
|
197
|
|
|
197
|
|
|
@@
-225,6
+225,16
namespace Implab {
|
|
225
|
return medium;
|
|
225
|
return medium;
|
|
226
|
}
|
|
226
|
}
|
|
227
|
|
|
227
|
|
|
|
|
|
228
|
public IPromiseBase Then(Action success,ErrorHandler error)
|
|
|
|
|
229
|
{
|
|
|
|
|
230
|
return Then(x => success(), error);
|
|
|
|
|
231
|
}
|
|
|
|
|
232
|
|
|
|
|
|
233
|
public IPromiseBase Then(Action success)
|
|
|
|
|
234
|
{
|
|
|
|
|
235
|
return Then(success);
|
|
|
|
|
236
|
}
|
|
|
|
|
237
|
|
|
228
|
/// <summary>
|
|
238
|
/// <summary>
|
|
229
|
/// Adds new handlers to this promise.
|
|
239
|
/// Adds new handlers to this promise.
|
|
230
|
/// </summary>
|
|
240
|
/// </summary>
|
|
@@
-232,7
+242,7
namespace Implab {
|
|
232
|
/// This handler will recieve an operation result as a parameter.</param>
|
|
242
|
/// This handler will recieve an operation result as a parameter.</param>
|
|
233
|
/// <param name="error">Handles an exception that may occur during the operation and returns the value which will be used as the result of the operation.</param>
|
|
243
|
/// <param name="error">Handles an exception that may occur during the operation and returns the value which will be used as the result of the operation.</param>
|
|
234
|
/// <returns>The new promise chained to this one.</returns>
|
|
244
|
/// <returns>The new promise chained to this one.</returns>
|
|
235
|
public Promise<T> Then(ResultHandler<T> success, ErrorHandler<T> error) {
|
|
245
|
public IPromise<T> Then(ResultHandler<T> success, ErrorHandler<T> error) {
|
|
236
|
if (success == null && error == null)
|
|
246
|
if (success == null && error == null)
|
|
237
|
return this;
|
|
247
|
return this;
|
|
238
|
|
|
248
|
|
|
@@
-266,7
+276,7
namespace Implab {
|
|
266
|
}
|
|
276
|
}
|
|
267
|
|
|
277
|
|
|
268
|
|
|
278
|
|
|
269
|
public Promise<T> Then(ResultHandler<T> success) {
|
|
279
|
public IPromise<T> Then(ResultHandler<T> success) {
|
|
270
|
if (success == null)
|
|
280
|
if (success == null)
|
|
271
|
return this;
|
|
281
|
return this;
|
|
272
|
|
|
282
|
|
|
@@
-287,8
+297,8
namespace Implab {
|
|
287
|
return medium;
|
|
297
|
return medium;
|
|
288
|
}
|
|
298
|
}
|
|
289
|
|
|
299
|
|
|
290
|
public Promise<T> Error(ErrorHandler error) {
|
|
300
|
public IPromise<T> Error(ErrorHandler error) {
|
|
291
|
return Then(null, error);
|
|
301
|
return Then((ResultHandler<T>)null, error);
|
|
292
|
}
|
|
302
|
}
|
|
293
|
|
|
303
|
|
|
294
|
/// <summary>
|
|
304
|
/// <summary>
|
|
@@
-299,7
+309,7
namespace Implab {
|
|
299
|
/// </remarks>
|
|
309
|
/// </remarks>
|
|
300
|
/// <param name="handler">The error handler which returns the result of the promise.</param>
|
|
310
|
/// <param name="handler">The error handler which returns the result of the promise.</param>
|
|
301
|
/// <returns>New promise.</returns>
|
|
311
|
/// <returns>New promise.</returns>
|
|
302
|
public Promise<T> Error(ErrorHandler<T> handler) {
|
|
312
|
public IPromise<T> Error(ErrorHandler<T> handler) {
|
|
303
|
if (handler == null)
|
|
313
|
if (handler == null)
|
|
304
|
return this;
|
|
314
|
return this;
|
|
305
|
|
|
315
|
|
|
@@
-320,7
+330,7
namespace Implab {
|
|
320
|
return medium;
|
|
330
|
return medium;
|
|
321
|
}
|
|
331
|
}
|
|
322
|
|
|
332
|
|
|
323
|
public Promise<T> Anyway(Action handler) {
|
|
333
|
public IPromise<T> Anyway(Action handler) {
|
|
324
|
if (handler == null)
|
|
334
|
if (handler == null)
|
|
325
|
return this;
|
|
335
|
return this;
|
|
326
|
|
|
336
|
|
|
@@
-358,7
+368,7
namespace Implab {
|
|
358
|
/// <param name="error">Обработчик ошибки. Данный обработчик получит
|
|
368
|
/// <param name="error">Обработчик ошибки. Данный обработчик получит
|
|
359
|
/// исключение возникшее при выполнении операции.</param>
|
|
369
|
/// исключение возникшее при выполнении операции.</param>
|
|
360
|
/// <returns>Новое обещание, которое будет выполнено при выполнении исходного обещания.</returns>
|
|
370
|
/// <returns>Новое обещание, которое будет выполнено при выполнении исходного обещания.</returns>
|
|
361
|
public Promise<TNew> Map<TNew>(ResultMapper<T, TNew> mapper, ErrorHandler error) {
|
|
371
|
public IPromise<TNew> Map<TNew>(ResultMapper<T, TNew> mapper, ErrorHandler error) {
|
|
362
|
if (mapper == null)
|
|
372
|
if (mapper == null)
|
|
363
|
throw new ArgumentNullException("mapper");
|
|
373
|
throw new ArgumentNullException("mapper");
|
|
364
|
|
|
374
|
|
|
@@
-385,7
+395,7
namespace Implab {
|
|
385
|
return chained;
|
|
395
|
return chained;
|
|
386
|
}
|
|
396
|
}
|
|
387
|
|
|
397
|
|
|
388
|
public Promise<TNew> Map<TNew>(ResultMapper<T, TNew> mapper) {
|
|
398
|
public IPromise<TNew> Map<TNew>(ResultMapper<T, TNew> mapper) {
|
|
389
|
return Map(mapper, null);
|
|
399
|
return Map(mapper, null);
|
|
390
|
}
|
|
400
|
}
|
|
391
|
|
|
401
|
|
|
@@
-399,7
+409,7
namespace Implab {
|
|
399
|
/// <param name="error">Обработчик ошибки. Данный обработчик получит
|
|
409
|
/// <param name="error">Обработчик ошибки. Данный обработчик получит
|
|
400
|
/// исключение возникшее при выполнении текуещй операции.</param>
|
|
410
|
/// исключение возникшее при выполнении текуещй операции.</param>
|
|
401
|
/// <returns>Новое обещание, которое будет выполнено по окончанию указанной аснхронной операции.</returns>
|
|
411
|
/// <returns>Новое обещание, которое будет выполнено по окончанию указанной аснхронной операции.</returns>
|
|
402
|
public Promise<TNew> Chain<TNew>(ChainedOperation<T, TNew> chained, ErrorHandler error) {
|
|
412
|
public IPromise<TNew> Chain<TNew>(ChainedOperation<T, TNew> chained, ErrorHandler error) {
|
|
403
|
|
|
413
|
|
|
404
|
// проблема в том, что на момент связывания еще не начата асинхронная операция, поэтому нужно
|
|
414
|
// проблема в том, что на момент связывания еще не начата асинхронная операция, поэтому нужно
|
|
405
|
// создать посредника, к которому будут подвызяваться следующие обработчики.
|
|
415
|
// создать посредника, к которому будут подвызяваться следующие обработчики.
|
|
@@
-437,11
+447,11
namespace Implab {
|
|
437
|
return medium;
|
|
447
|
return medium;
|
|
438
|
}
|
|
448
|
}
|
|
439
|
|
|
449
|
|
|
440
|
public Promise<TNew> Chain<TNew>(ChainedOperation<T, TNew> chained) {
|
|
450
|
public IPromise<TNew> Chain<TNew>(ChainedOperation<T, TNew> chained) {
|
|
441
|
return Chain(chained, null);
|
|
451
|
return Chain(chained, null);
|
|
442
|
}
|
|
452
|
}
|
|
443
|
|
|
453
|
|
|
444
|
public Promise<T> Cancelled(Action handler) {
|
|
454
|
public IPromise<T> Cancelled(Action handler) {
|
|
445
|
AddHandler(null, null, handler);
|
|
455
|
AddHandler(null, null, handler);
|
|
446
|
return this;
|
|
456
|
return this;
|
|
447
|
}
|
|
457
|
}
|
|
@@
-451,7
+461,7
namespace Implab {
|
|
451
|
/// </summary>
|
|
461
|
/// </summary>
|
|
452
|
/// <param name="handler">The handler that will be called anyway</param>
|
|
462
|
/// <param name="handler">The handler that will be called anyway</param>
|
|
453
|
/// <returns>self</returns>
|
|
463
|
/// <returns>self</returns>
|
|
454
|
public Promise<T> Finally(Action handler) {
|
|
464
|
public IPromise<T> Finally(Action handler) {
|
|
455
|
if (handler == null)
|
|
465
|
if (handler == null)
|
|
456
|
throw new ArgumentNullException("handler");
|
|
466
|
throw new ArgumentNullException("handler");
|
|
457
|
AddHandler(
|
|
467
|
AddHandler(
|