当前位置: 首页>>代码示例>>C#>>正文


C# IExtensionManager.IsDisabled方法代码示例

本文整理汇总了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;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:32,代码来源:CodeRefactoringProducer.cs

示例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);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:AbstractCodeRefactoringService.cs

示例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;
        }
开发者ID:tralivali1234,项目名称:roslyn,代码行数:49,代码来源:CodeRefactoringService.cs


注:本文中的IExtensionManager.IsDisabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。