本文整理汇总了C#中FieldDeclaration.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# FieldDeclaration.Clone方法的具体用法?C# FieldDeclaration.Clone怎么用?C# FieldDeclaration.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldDeclaration
的用法示例。
在下文中一共展示了FieldDeclaration.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActions
IEnumerable<CodeAction> GetActions(Attribute attribute, AttributeSection attributeSection, FieldDeclaration fieldDeclaration)
{
string removeAttributeMessage = ctx.TranslateString("Remove attribute");
yield return new CodeAction(removeAttributeMessage, script => {
if (attributeSection.Attributes.Count > 1) {
var newSection = new AttributeSection();
newSection.AttributeTarget = attributeSection.AttributeTarget;
foreach (var attr in attributeSection.Attributes) {
if (attr != attribute)
newSection.Attributes.Add((Attribute)attr.Clone());
}
script.Replace(attributeSection, newSection);
} else {
script.Remove(attributeSection);
}
});
var makeStaticMessage = ctx.TranslateString("Make the field static");
yield return new CodeAction(makeStaticMessage, script => {
var newDeclaration = (FieldDeclaration)fieldDeclaration.Clone();
newDeclaration.Modifiers |= Modifiers.Static;
script.Replace(fieldDeclaration, newDeclaration);
});
}