本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Binder.BindAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.BindAttribute方法的具体用法?C# Binder.BindAttribute怎么用?C# Binder.BindAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Binder
的用法示例。
在下文中一共展示了Binder.BindAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bind
internal override BoundNode Bind(Binder binder, CSharpSyntaxNode node, DiagnosticBag diagnostics)
{
if (node.Kind == SyntaxKind.Attribute)
{
var attribute = (AttributeSyntax)node;
return binder.BindAttribute(attribute, AttributeType, diagnostics);
}
else if (SyntaxFacts.IsAttributeName(node))
{
return new BoundTypeExpression((NameSyntax)node, aliasOpt, inferredType: false, type: AttributeType);
}
else
{
return base.Bind(binder, node, diagnostics);
}
}
示例2: GetSpeculativelyBoundAttribute
/// <summary>
/// Bind the given attribute speculatively at the given position, and return back
/// the resulting bound node. May return null in some error cases.
/// </summary>
private BoundAttribute GetSpeculativelyBoundAttribute(int position, AttributeSyntax attribute, out Binder binder)
{
if (attribute == null)
{
throw new ArgumentNullException(nameof(attribute));
}
binder = this.GetSpeculativeBinderForAttribute(position);
if (binder == null)
{
return null;
}
var diagnostics = DiagnosticBag.GetInstance();
AliasSymbol aliasOpt; // not needed.
NamedTypeSymbol attributeType = (NamedTypeSymbol)binder.BindType(attribute.Name, diagnostics, out aliasOpt);
var boundNode = binder.BindAttribute(attribute, attributeType, diagnostics);
diagnostics.Free();
return boundNode;
}