本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.ExecutableCodeBinder.GetBinder方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutableCodeBinder.GetBinder方法的具体用法?C# ExecutableCodeBinder.GetBinder怎么用?C# ExecutableCodeBinder.GetBinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.ExecutableCodeBinder
的用法示例。
在下文中一共展示了ExecutableCodeBinder.GetBinder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSpeculativeSemanticModelForMethodBody
private bool GetSpeculativeSemanticModelForMethodBody(SyntaxTreeSemanticModel parentModel, int position, BlockSyntax body, out SemanticModel speculativeModel)
{
position = CheckAndAdjustPosition(position);
var methodSymbol = (MethodSymbol)this.MemberSymbol;
var executablebinder = new ExecutableCodeBinder(body, methodSymbol, this.rootBinder.Next); // Strip off ExecutableCodeBinder (see ctor).
var blockBinder = executablebinder.GetBinder(body).WithAdditionalFlags(BinderFlags.SemanticModel);
speculativeModel = CreateSpeculative(parentModel, methodSymbol, body, blockBinder, position);
return true;
}
示例2: GetSpeculativeSemanticModelForMethodBody
private bool GetSpeculativeSemanticModelForMethodBody(SyntaxTreeSemanticModel parentModel, int position, BlockSyntax body, out SemanticModel speculativeModel)
{
position = CheckAndAdjustPosition(position);
var methodSymbol = (MethodSymbol)this.MemberSymbol;
// Strip off ExecutableCodeBinder (see ctor).
Binder binder = this.RootBinder;
do
{
if (binder is ExecutableCodeBinder)
{
binder = binder.Next;
break;
}
binder = binder.Next;
}
while (binder != null);
Debug.Assert(binder != null);
var executablebinder = new ExecutableCodeBinder(body, methodSymbol, binder ?? this.RootBinder);
var blockBinder = executablebinder.GetBinder(body).WithAdditionalFlags(GetSemanticModelBinderFlags());
speculativeModel = CreateSpeculative(parentModel, methodSymbol, body, blockBinder, position);
return true;
}
示例3: GetLambdaEnclosingBinder
/// <summary>
/// Performs the same function as GetEnclosingBinder, but is known to take place within a
/// specified lambda. Walks up the syntax hierarchy until a node with an associated binder
/// is found.
/// </summary>
/// <remarks>
/// CONSIDER: can this share code with MemberSemanticModel.GetEnclosingBinder?
///
/// Returned binder doesn't need to have <see cref="BinderFlags.SemanticModel"/> set - the caller will add it.
/// </remarks>
private static Binder GetLambdaEnclosingBinder(int position, CSharpSyntaxNode startingNode, CSharpSyntaxNode containingLambda, ExecutableCodeBinder lambdaBinder)
{
Debug.Assert(containingLambda.IsAnonymousFunction());
Debug.Assert(LookupPosition.IsInAnonymousFunctionOrQuery(position, containingLambda));
var current = startingNode;
while (current != containingLambda)
{
Debug.Assert(current != null);
StatementSyntax stmt = current as StatementSyntax;
if (stmt != null)
{
if (LookupPosition.IsInStatementScope(position, stmt))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else if (current.Kind == SyntaxKind.CatchClause)
{
if (LookupPosition.IsInCatchBlockScope(position, (CatchClauseSyntax)current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else if (current.Kind == SyntaxKind.CatchFilterClause)
{
if (LookupPosition.IsInCatchFilterScope(position, (CatchFilterClauseSyntax)current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else if (current.IsAnonymousFunction())
{
if (LookupPosition.IsInAnonymousFunctionOrQuery(position, current))
{
Binder binder = lambdaBinder.GetBinder(current);
if (binder != null)
{
return binder;
}
}
}
else
{
// If this ever breaks, make sure that all callers of
// CanHaveAssociatedLocalBinder are in sync.
Debug.Assert(!current.CanHaveAssociatedLocalBinder());
}
current = current.ParentOrStructuredTriviaParent;
}
return lambdaBinder;
}