本文整理汇总了C#中RefactoringContext.Supports方法的典型用法代码示例。如果您正苦于以下问题:C# RefactoringContext.Supports方法的具体用法?C# RefactoringContext.Supports怎么用?C# RefactoringContext.Supports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RefactoringContext
的用法示例。
在下文中一共展示了RefactoringContext.Supports方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActions
public override IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
if (!context.Supports(minimumVersion))
yield break;
var varDecl = GetVariableDeclarationStatement(context);
var foreachStmt = GetForeachStatement(context);
if (varDecl == null && foreachStmt == null) {
yield break;
}
yield return new CodeAction(context.TranslateString("Use 'var' keyword"), script => {
if (varDecl != null) {
script.Replace(varDecl.Type, new SimpleType ("var"));
} else {
script.Replace(foreachStmt.VariableType, new SimpleType ("var"));
}
}, (AstNode)varDecl ?? foreachStmt);
}
示例2: GetBackingField
static IField GetBackingField (RefactoringContext context)
{
var propertyDeclaration = context.GetNode<PropertyDeclaration> ();
// automatic properties always need getter & setter
if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull)
return null;
if (!context.Supports(csharp3) || propertyDeclaration.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ClassType.Interface)
return null;
var getterField = ScanGetter (context, propertyDeclaration);
if (getterField == null)
return null;
var setterField = ScanSetter (context, propertyDeclaration);
if (setterField == null)
return null;
if (getterField.Region != setterField.Region)
return null;
return getterField;
}