-
-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability in
IAwaitableFactory
to create result expression
- Loading branch information
Showing
7 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD, and Contributors. | ||
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Linq.Expressions; | ||
|
||
namespace Moq.Async | ||
{ | ||
internal sealed class AwaitExpression : Expression | ||
{ | ||
private readonly IAwaitableFactory awaitableFactory; | ||
private readonly Expression operand; | ||
|
||
public AwaitExpression(Expression operand, IAwaitableFactory awaitableFactory) | ||
{ | ||
Debug.Assert(awaitableFactory != null); | ||
Debug.Assert(operand != null); | ||
|
||
this.awaitableFactory = awaitableFactory; | ||
this.operand = operand; | ||
} | ||
|
||
public override bool CanReduce => false; | ||
|
||
public override ExpressionType NodeType => ExpressionType.Extension; | ||
|
||
public Expression Operand => this.operand; | ||
|
||
public override Type Type => this.awaitableFactory.ResultType; | ||
|
||
public override string ToString() | ||
{ | ||
return this.awaitableFactory.ResultType == typeof(void) ? $"await {this.operand}" | ||
: $"(await {this.operand})"; | ||
} | ||
|
||
protected override Expression VisitChildren(ExpressionVisitor visitor) => this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters