本文整理汇总了C#中Promise.Project方法的典型用法代码示例。如果您正苦于以下问题:C# Promise.Project方法的具体用法?C# Promise.Project怎么用?C# Promise.Project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Promise
的用法示例。
在下文中一共展示了Promise.Project方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RejectionOfSourcePromiseRejectsTransformedPromise
public void RejectionOfSourcePromiseRejectsTransformedPromise()
{
var promise = new Promise<int>();
var ex = new Exception();
var errors = 0;
promise
.Project(v => v.ToString(CultureInfo.InvariantCulture))
.Catch(e =>
{
Assert.AreEqual(ex, e);
++errors;
});
promise.Reject(ex);
Assert.AreEqual(1, errors);
}
示例2: ExceptionThrownDuringTransformRejectsTransformedPromise
public void ExceptionThrownDuringTransformRejectsTransformedPromise()
{
var promise = new Promise<int>();
const int promisedValue = 15;
var errors = 0;
var ex = new Exception();
promise
.Project<string>(v =>
{
throw ex;
})
.Catch(e =>
{
Assert.AreEqual(ex, e);
++errors;
});
promise.Resolve(promisedValue);
Assert.AreEqual(1, errors);
}
示例3: CanTransformPromiseValue
public void CanTransformPromiseValue()
{
var promise = new Promise<int>();
const int promisedValue = 15;
var completed = 0;
promise
.Project(v => v.ToString(CultureInfo.InvariantCulture))
.Then(v =>
{
Assert.AreEqual(promisedValue.ToString(CultureInfo.InvariantCulture), v);
++completed;
});
promise.Resolve(promisedValue);
Assert.AreEqual(1, completed);
}