本文整理汇总了C#中SyntaxGenerator.AwaitExpression方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxGenerator.AwaitExpression方法的具体用法?C# SyntaxGenerator.AwaitExpression怎么用?C# SyntaxGenerator.AwaitExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxGenerator
的用法示例。
在下文中一共展示了SyntaxGenerator.AwaitExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProxyVaraibleDeclaration
private SyntaxNode CreateProxyVaraibleDeclaration(SyntaxGenerator g, GenerationNameTable nameTable, bool isAsync)
{
// var proxy = this.GetProxy();
if (!isAsync)
{
return g.LocalDeclarationStatement(nameTable[MemberNames.ProxyVariable],
g.InvocationExpression(
g.MemberAccessExpression(
g.ThisExpression(),
g.IdentifierName(nameTable[MemberNames.GetProxyMethod])
)
)
);
}
else
{
// var proxy = await this.GetProxyAsync().ConfigureAwait(false);
return
g.LocalDeclarationStatement(nameTable[MemberNames.ProxyVariable],
g.AwaitExpression(
g.InvocationExpression(
g.MemberAccessExpression(
g.InvocationExpression(
g.MemberAccessExpression(
g.ThisExpression(),
g.IdentifierName(nameTable[MemberNames.GetProxyAsyncMethod])
)
), "ConfigureAwait"),
g.FalseLiteralExpression()
)
)
);
}
}
示例2: CreateProxyInvocationStatement
private SyntaxNode CreateProxyInvocationStatement(Compilation compilation, SyntaxGenerator g, GenerationNameTable nameTable, IMethodSymbol sourceMethod)
{
bool isAsync = ReturnsTask(compilation, sourceMethod);
bool isVoid = IsVoid(compilation, sourceMethod);
// proxy.Method(arg1, arg2, ...);
SyntaxNode invocation = g.InvocationExpression(
g.MemberAccessExpression(
g.IdentifierName(nameTable[MemberNames.ProxyVariable]),
sourceMethod.Name
),
sourceMethod.Parameters.Select(p => g.IdentifierName(p.Name))
);
if (isAsync)
{
// await proxy.Method(arg1, arg2, ...).ConfigureAwait(false);
invocation =
g.AwaitExpression(
g.InvocationExpression(
g.MemberAccessExpression(
invocation,
"ConfigureAwait"
),
g.FalseLiteralExpression()
)
);
}
if (isVoid)
{
invocation = g.ExpressionStatement(invocation);
}
else
{
invocation = g.ReturnStatement(invocation);
}
return invocation;
}