本文整理汇总了C#中IExtensionManager.IsDisabled方法的典型用法代码示例。如果您正苦于以下问题:C# IExtensionManager.IsDisabled方法的具体用法?C# IExtensionManager.IsDisabled怎么用?C# IExtensionManager.IsDisabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExtensionManager
的用法示例。
在下文中一共展示了IExtensionManager.IsDisabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRefactoringFromProvider
private async Task<CodeRefactoring> GetRefactoringFromProvider(
CodeRefactoringProvider provider,
IExtensionManager extensionManager,
CodeRefactoringContext context)
{
context.CancellationToken.ThrowIfCancellationRequested();
if (extensionManager.IsDisabled(provider))
{
return null;
}
try
{
var actions = await provider.GetRefactoringsAsync(context).ConfigureAwait(false);
if (actions != null && actions.Count() > 0)
{
return new CodeRefactoring(provider, actions);
}
}
catch (OperationCanceledException)
{
// We don't want to catch operation canceled exceptions in the catch block
// below. So catch is here and rethrow it.
throw;
}
catch (Exception e)
{
extensionManager.HandleException(provider, e);
}
return null;
}
示例2: AddRefactoringAsync
private async Task AddRefactoringAsync(
CodeRefactoringProvider provider,
List<CodeRefactoring> allRefactorings,
IExtensionManager extensionManager,
CodeRefactoringContext context)
{
try
{
if (!extensionManager.IsDisabled(provider))
{
using (Logger.LogBlock(FeatureId.CodeActions, FunctionId.CodeAction_AddRefactoring, codeRefactoringDescription, provider, context.Span, context.CancellationToken))
{
var actions = await provider.GetRefactoringsAsync(context).ConfigureAwait(false);
if (actions != null && actions.Count() > 0)
{
allRefactorings.Add(new CodeRefactoring(provider, actions));
}
}
}
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception e)
{
extensionManager.HandleException(provider, e);
}
}
示例3: GetRefactoringFromProviderAsync
private async Task<CodeRefactoring> GetRefactoringFromProviderAsync(
Document document,
TextSpan state,
CodeRefactoringProvider provider,
IExtensionManager extensionManager,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (extensionManager.IsDisabled(provider))
{
return null;
}
try
{
var actions = new List<CodeAction>();
var context = new CodeRefactoringContext(document, state,
// TODO: Can we share code between similar lambdas that we pass to this API in BatchFixAllProvider.cs, CodeFixService.cs and CodeRefactoringService.cs?
a =>
{
// Serialize access for thread safety - we don't know what thread the refactoring provider will call this delegate from.
lock (actions)
{
actions.Add(a);
}
},
cancellationToken);
var task = provider.ComputeRefactoringsAsync(context) ?? SpecializedTasks.EmptyTask;
await task.ConfigureAwait(false);
if (actions.Count > 0)
{
return new CodeRefactoring(provider, actions);
}
}
catch (OperationCanceledException)
{
// We don't want to catch operation canceled exceptions in the catch block
// below. So catch is here and rethrow it.
throw;
}
catch (Exception e)
{
extensionManager.HandleException(provider, e);
}
return null;
}