本文整理汇总了C#中IdentifierExpression.CopyAnnotationsFrom方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression.CopyAnnotationsFrom方法的具体用法?C# IdentifierExpression.CopyAnnotationsFrom怎么用?C# IdentifierExpression.CopyAnnotationsFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentifierExpression
的用法示例。
在下文中一共展示了IdentifierExpression.CopyAnnotationsFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveTransparentIdentifierReferences
/// <summary>
/// Removes all occurrences of transparent identifiers
/// </summary>
void RemoveTransparentIdentifierReferences(AstNode node, string transparentIdentifier)
{
foreach (AstNode child in node.Children) {
RemoveTransparentIdentifierReferences(child, transparentIdentifier);
}
MemberReferenceExpression mre = node as MemberReferenceExpression;
if (mre != null) {
IdentifierExpression ident = mre.Target as IdentifierExpression;
if (ident != null && ident.Identifier == transparentIdentifier) {
IdentifierExpression newIdent = new IdentifierExpression(mre.MemberName);
mre.TypeArguments.MoveTo(newIdent.TypeArguments);
newIdent.CopyAnnotationsFrom(mre);
newIdent.RemoveAnnotations<PropertyDeclaration>(); // remove the reference to the property of the anonymous type
mre.ReplaceWith(newIdent);
return;
} else if (mre.MemberName == transparentIdentifier) {
var newVar = mre.Target.Detach();
newVar.CopyAnnotationsFrom(mre);
newVar.RemoveAnnotations<PropertyDeclaration>(); // remove the reference to the property of the anonymous type
mre.ReplaceWith(newVar);
return;
}
}
}