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


C# ISolution.GetComponent方法代码示例

本文整理汇总了C#中ISolution.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# ISolution.GetComponent方法的具体用法?C# ISolution.GetComponent怎么用?C# ISolution.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISolution的用法示例。


在下文中一共展示了ISolution.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            if (!MethodDeclaration.IsValid())
            {
                return;
            }

            var containingFile = MethodDeclaration.GetContainingFile();
            var psiModule = MethodDeclaration.GetPsiModule();
            var elementFactory = CSharpElementFactory.GetInstance(psiModule);
            var declared = MethodDeclaration.DeclaredElement;
            if (declared != null)
            {
                var newName = declared.ShortName + "Async";

                var refactoringService = solution.GetComponent<RenameRefactoringService>();
                var suggests = new List<string> {newName};
                SearchDomainFactory searchDomainFactory = solution.GetComponent<SearchDomainFactory>();
                var workflow = (IRefactoringWorkflow)new MethodRenameWorkflow(suggests, solution.GetComponent<IShellLocks>(), searchDomainFactory, refactoringService, solution, "TypoRename");

                var renames = RenameRefactoringService.Instance.CreateAtomicRenames(declared, newName, true).ToList();
               // var workflow = RenameFromContexts.InitFromNameChanges(solution, renames);
                //                workflow.CreateRefactoring();
                Lifetimes.Using(lifetime => RefactoringActionUtil.ExecuteRefactoring(solution.GetComponent<IActionManager>().DataContexts.CreateOnSelection(lifetime, DataRules.AddRule("DoTypoRenameWorkflow", DataConstants.SOLUTION, solution)), workflow));
            }
        }
开发者ID:miniBill,项目名称:AsyncSuffix,代码行数:26,代码来源:ConsiderUsingAsyncSuffixBulbItem.cs

示例2: Execute

    public void Execute(ISolution solution, ITextControl textControl)
    {
      if (!_literalExpression.IsValid())
        return;

      IFile containingFile = _literalExpression.GetContainingFile();

      CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(_literalExpression.GetPsiModule());

      IExpression newExpression = null;
      _literalExpression.GetPsiServices().PsiManager.DoTransaction(
        () =>
          {
            using (solution.GetComponent<IShellLocks>().UsingWriteLock())
              newExpression = ModificationUtil.ReplaceChild(
                _literalExpression, elementFactory.CreateExpression("System.Int16.MaxValue"));
          }, GetType().Name);

      if (newExpression != null)
      {
        IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
        containingFile.OptimizeImportsAndRefs(
          marker, false, true, NullProgressIndicator.Instance);
      }
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:25,代码来源:UseOfInt16MaxValueLiteralBulbItem.cs

示例3: ExecutePsiTransaction

        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            var unitTestSessionManager = solution.GetComponent<IUnitTestSessionManager>();

              var element = MethodRunnerElement.GetInstance(solution.GetComponent<MethodRunnerProvider>(), myClassDeclaration.GetClrName().FullName, myMethodDeclaration.DeclaredName, myClassDeclaration.IsStatic, myMethodDeclaration.IsStatic);

              var sessionView = unitTestSessionManager.CreateSession();

              sessionView.RunAll(solution.GetComponent<ProcessHostProvider>());

              return null;
        }
开发者ID:flcdrg,项目名称:ReSharper-TestToolsPlugin,代码行数:12,代码来源:RunMethodAction.cs

示例4: DoTransaction

        private static IJavaScriptTreeNode DoTransaction(ISolution solution, JavaScriptElementFactory elementFactory,
		                                                 Func<JavaScriptElementFactory, IJavaScriptTreeNode> addMethod)
        {
            IJavaScriptTreeNode newExpression;
            using (solution.GetComponent<IShellLocks>().UsingWriteLock())
            {
                newExpression = addMethod(elementFactory);
            }
            return newExpression;
        }
开发者ID:cfiet,项目名称:resharper-jshint,代码行数:10,代码来源:UseStrictQuickFix.cs

示例5: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            try
            {
                if (!_literalExpression.IsValid())
                {
                    return;
                }

                var psiModule = _literalExpression.GetPsiModule();
                var psiManager = _literalExpression.GetPsiServices().PsiManager;

                var containingFile = _literalExpression.GetContainingFile();
                var csharpFile = containingFile as ICSharpFile;

                var elementFactory = CSharpElementFactory.GetInstance(psiModule);

                IExpression newExpression = null;
                psiManager.DoTransaction(
                    () =>
                        {
                            using (solution.GetComponent<IShellLocks>().UsingWriteLock())
                            {
                                var replacementExpression =
                                    elementFactory.CreateExpression(_literalExpression.GetText() + ".AsObservable()");
                                newExpression = ModificationUtil.ReplaceChild(_literalExpression, replacementExpression);

                                EnsureNamespaceExists(csharpFile, elementFactory);
                            }
                        }, GetType().Name);

                if (newExpression != null)
                {
                    var marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
                    containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
                }
            }
            catch (Exception exn)
            {
                Debug.WriteLine("Failed AsObservableBulbItem, exception message - '{0}'", exn.Message);
            }
        }
开发者ID:oriches,项目名称:Resharper.ReactivePlugin,代码行数:42,代码来源:AsObservableBulbItem.cs

示例6: Execute

 public void Execute(ISolution solution, ITextControl textControl)
 {
     if (!MethodDeclaration.IsValid())
     {
         return;
     }
     var declared = MethodDeclaration.DeclaredElement;
     if (declared != null)
     {
         var suggests = AsyncMethodNameSuggestions.Get(MethodDeclaration);
         var workflow =
             (IRefactoringWorkflow)
                 new MethodRenameWorkflow(suggests, solution.GetComponent<RenameRefactoringService>(), solution, "AsyncSuffixMethodRename");
         Lifetimes.Using(lifetime =>
         {
             var dataRules = DataRules.AddRule("DoAsyncMethodRenameWorkflow", ProjectModelDataConstants.SOLUTION, solution);
             var dataContext = solution.GetComponent<IActionManager>().DataContexts.CreateOnSelection(lifetime, dataRules);
             RefactoringActionUtil.ExecuteRefactoring(dataContext, workflow);
         });
     }
 }
开发者ID:asizikov,项目名称:AsyncSuffix,代码行数:21,代码来源:ConsiderUsingAsyncSuffixBulbItem.cs

示例7: ExecuteTransactionInner

        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            Lifetimes.Using(
                lifetime =>
                    {
                        StyleCopApi api = solution.GetComponent<StyleCopApiPool>().GetInstance(lifetime);

                        Settings settings = api.Settings.GetSettings(file.GetSourceFile().ToProjectFile());

                        // Fixes SA1208, SA1209, SA1210, SA1211
                        OrderingRules.ExecuteAll(file, settings);
                    });
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:24,代码来源:OrderUsingsBulbItem.cs

示例8: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            if (!_literalExpression.IsValid())
                return;

            var containingFile = _literalExpression.GetContainingFile();
            var psiModule = _literalExpression.GetPsiModule();
            var elementFactory = CSharpElementFactory.GetInstance(psiModule);

            IExpression newExpression = null;
            _literalExpression.GetPsiServices().Transactions.Execute(GetType().Name, () =>
            {
                using (solution.GetComponent<IShellLocks>().UsingWriteLock())
                    newExpression = ModificationUtil.ReplaceChild(
                      _literalExpression.Task, elementFactory.CreateExpression("$0.ConfigureAwait($1)", _literalExpression.Task,
                        elementFactory.CreateExpressionByConstantValue(CSharpConstantValueFactory.CreateBoolValue(_value, psiModule))));
            });

            if (newExpression != null)
            {
                IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
                containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
            }
        }
开发者ID:hmemcpy,项目名称:ConfigureAwaitChecker,代码行数:24,代码来源:ConsiderUsingConfigureAwaitBulbItem.cs

示例9: YouTrackPowerToyOptionsPage

        public YouTrackPowerToyOptionsPage(IOptionsDialog optionsDialog, ISolution solution)
        {
            this.solution = solution;

            if (this.solution != null)
            {
                InitializeComponent();
                this.youTrackSettings = solution.GetComponent<YouTrackSettings>();
                this.youTrackSettingsControl = new YouTrackSettingsControl(this.youTrackSettings);

                this.Controls.Add(this.youTrackSettingsControl);
            }
            else
            {
                Controls.Add(JetBrains.UI.Options.Helpers.Controls.CreateNoSolutionCueBanner());
                //Controls.Add(new RichTextLabel("You need to have an open solution to access these settings"));
            }
        }
开发者ID:e-llumin,项目名称:YouTrackForReSharper,代码行数:18,代码来源:YouTrackPowerToyOptionsPage.cs

示例10: ExploreSolution

 public void ExploreSolution(ISolution solution, UnitTestElementConsumer consumer)
 {
     TestCache component;
     try
     {
         component = solution.GetComponent<TestCache>();
     }
     catch
     {
         return;
     }
     component.ReanalyzeDirtyFiles();
     foreach (var element in from e in component.UnitTestElements
         where e.State.IsValid() && (e.Provider is KarmaTestProvider)
         select e)
     {
         consumer(element);
     }
 }
开发者ID:sergeyt,项目名称:karma-resharper,代码行数:19,代码来源:KarmaTestProvider.cs

示例11: ExecuteTransactionInner

        /// <inheritdoc />
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            Lifetimes.Using(
                lifetime =>
                    {
                        StyleCopApi api = solution.GetComponent<StyleCopApiPool>().GetInstance(lifetime);

                        var settings = api.Settings.GetSettings(file.GetSourceFile().ToProjectFile());

                        // this covers the issue that constants (and maybe others) return the class if called as GetContainingElement<IDeclaration>)
                        IDeclaration declaration = Utils.GetTypeClosestToTextControl<IDeclaration>(solution, textControl);

                        if (declaration != null)
                        {
                            DocumentationRules.CheckDeclarationDocumentation(file, declaration, settings);
                        }
                    });
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:21,代码来源:SA1600ElementsMustBeDocumentedBulbItem.cs

示例12: ExecutePsiTransaction

        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            if (!expression.IsValid())
                return null;

            IFile containingFile = expression.GetContainingFile();

            JavaScriptElementFactory elementFactory = JavaScriptElementFactory.GetInstance(expression.GetPsiModule(), JavaScriptLanguage.Instance);

            IJavaScriptTreeNode newExpression = null;
            Func<JavaScriptElementFactory, IJavaScriptTreeNode> addMethod = AddUseStrict;
            expression.GetPsiServices().PsiManager.DoTransaction(
              () =>
              {
                  newExpression = DoTransaction(solution, elementFactory, addMethod);
              }, GetType().Name);

            if (newExpression != null)
            {
                IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
                containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
            }
            return null;
        }
开发者ID:cfiet,项目名称:resharper-jshint,代码行数:24,代码来源:UseStrictQuickFix.cs

示例13: GetCache

 protected NTriplesCache GetCache(ISolution solution)
 {
     // always perform unscoped search
     return solution.GetComponent<NTriplesCache>();
 }
开发者ID:xsburg,项目名称:ReSharper.NTriples,代码行数:5,代码来源:NTriplesGotoSymbolProvider.cs

示例14: ExecutePsiTransaction

        /// <summary>
        /// Performs the QuickFix, ensures the file is both writable and creates a transaction.
        /// </summary>
        /// <param name="solution">
        /// Current Solution.
        /// </param>
        /// <param name="progress">
        /// Progress Indicator for the fix.
        /// </param>
        /// <returns>
        /// The execute transaction.
        /// </returns>
        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, JetBrains.Application.Progress.IProgressIndicator progress)
        {
            return delegate(ITextControl textControl)
                {
                    solution.GetComponent<DocumentManagerOperations>().SaveAllDocuments();

                    using (solution.GetComponent<DocumentTransactionManager>().CreateTransactionCookie(JetBrains.Util.DefaultAction.Commit, "action name"))
                    {
                        var services = solution.GetPsiServices();
                        services.Transactions.Execute(
                            "Code cleanup",
                            () => services.Locks.ExecuteWithWriteLock(() => { ExecuteTransactionInner(solution, textControl); }));
                    }
                };
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:27,代码来源:V5BulbItemImpl.cs

示例15: Execute

        public void Execute(ISolution solution, ITextControl textControl)
        {
            try
            {
                var psiManager = _expression.GetPsiServices().PsiManager;
                var sourceFile = _expression.GetSourceFile();
                if (sourceFile == null)
                {
                    // What not source file!
                    return;
                }

                var psiFile = sourceFile.GetNonInjectedPsiFile<CSharpLanguage>();
                if (psiFile == null)
                {
                    // It's not a CSharp file...
                    return;
                }

                var expressions = new List<IInvocationExpression>();
                psiFile.ProcessChildren<IInvocationExpression>(expressions.Add);

                var index = expressions.FindIndex(c => c == _expression);
                var previousIndex = index + 1;

                if (previousIndex > (expressions.Count - 1))
                {
                    // There isn't a previous invocation expression...
                    return;
                }

                var previousExpression = expressions[previousIndex];

                var firstChild = previousExpression.FirstChild;
                if (firstChild == null)
                {
                    return;
                }

                var arugmentList = previousExpression.Children<IArgumentList>().SingleOrDefault();
                if (arugmentList == null)
                {
                    return;
                }

                var containingFile = _expression.GetContainingFile();

                var elementFactory = CSharpElementFactory.GetInstance(sourceFile.PsiModule);

                IExpression newExpression = null;
                psiManager.DoTransaction(
                    () =>
                        {
                            using (solution.GetComponent<IShellLocks>().UsingWriteLock())
                            {
                                var preText = firstChild.GetText();
                                var arugmentListText = arugmentList.GetText();

                                var lastSelectIndex = preText.LastIndexOf(Constants.SelectMethodName,
                                                                          StringComparison.Ordinal);
                                var formattedPreText = preText.Remove(lastSelectIndex, Constants.SelectMethodName.Length)
                                                              .Insert(lastSelectIndex, Constants.SelectManyMethodName);

                                var replacementExpressionText = string.Format(ReplacementTextFormat, formattedPreText,
                                                                              arugmentListText);
                                var replacementExpression = elementFactory.CreateExpression(replacementExpressionText);

                                newExpression = ModificationUtil.ReplaceChild(_expression, replacementExpression);
                            }
                        }, GetType().Name);

                if (newExpression != null)
                {
                    var marker =
                        newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
                    containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
                }
            }
            catch (Exception exn)
            {
                Debug.WriteLine("Failed SelectAndMergeBulbItem, exception message - '{0}'", exn.Message);
            }
        }
开发者ID:oriches,项目名称:Resharper.ReactivePlugin,代码行数:83,代码来源:SelectAndMergeBulbItem.cs


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