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


C# IProgressIndicator.SafeTotal方法代码示例

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


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

示例1: Process

        public void Process(
            IPsiSourceFile sourceFile,
            IRangeMarker rangeMarkerMarker,
            CodeCleanupProfile profile,
            IProgressIndicator progressIndicator)
        {
            ISolution solution = sourceFile.GetSolution();
            if (!profile.GetSetting(OurDescriptor))
            {
                return;
            }

            INTriplesFile[] files = sourceFile.GetPsiFiles<NTriplesLanguage>().Cast<INTriplesFile>().ToArray();
            using (progressIndicator.SafeTotal("Reformat Psi", files.Length))
            {
                foreach (INTriplesFile file in files)
                {
                    using (IProgressIndicator pi = progressIndicator.CreateSubProgress(1))
                    {
                        using (WriteLockCookie.Create())
                        {
                            var languageService = file.Language.LanguageService();
                            Assertion.Assert(languageService != null, "languageService != null");
                            var formatter = languageService.CodeFormatter;
                            Assertion.Assert(formatter != null, "formatter != null");

                            PsiManager.GetInstance(sourceFile.GetSolution()).DoTransaction(
                                delegate
                                {
                                    if (rangeMarkerMarker != null && rangeMarkerMarker.IsValid)
                                    {
                                        formatter.Format(
                                            solution,
                                            rangeMarkerMarker.DocumentRange,
                                            CodeFormatProfile.DEFAULT,
                                            true,
                                            false,
                                            pi);
                                    }
                                    else
                                    {
                                        formatter.FormatFile(
                                            file,
                                            CodeFormatProfile.DEFAULT,
                                            pi);
                                    }
                                },
                                "Code cleanup");
                        }
                    }
                }
            }
        }
开发者ID:xsburg,项目名称:ReSharper.NTriples,代码行数:53,代码来源:ReformatCode.cs

示例2: Format

        public override ITreeRange Format(
            ITreeNode firstElement,
            ITreeNode lastElement,
            CodeFormatProfile profile,
            IProgressIndicator pi,
            IContextBoundSettingsStore overrideSettingsStore = null)
        {
            ITreeNode firstNode;
            ITreeNode lastNode;

            GetFirstAndLastNode(firstElement, lastElement, out firstNode, out lastNode);

            var contextBoundSettingsStore = this.GetProperContextBoundSettingsStore(overrideSettingsStore, firstNode);

            var globalSettings = GlobalFormatSettingsHelper
                .GetService(firstNode.GetSolution())
                .GetSettingsForLanguage(this.myLanguage, firstNode.GetProjectFileType(), contextBoundSettingsStore);

            using (pi.SafeTotal(4))
            {
                var context = new PsiCodeFormattingContext(this, firstNode, lastNode);
                if (profile != CodeFormatProfile.INDENT)
                {
                    using (IProgressIndicator subPi = pi.CreateSubProgress(2))
                    {
                        using (subPi.SafeTotal(2))
                        {
                            SecretFormattingStage.DoFormat(context, subPi.CreateSubProgress(1));
                            SecretIndentingStage.DoIndent(context, globalSettings, subPi.CreateSubProgress(1), false);
                        }
                    }
                }
                else
                {
                    using (IProgressIndicator subPi = pi.CreateSubProgress(4))
                    {
                        SecretIndentingStage.DoIndent(context, globalSettings, subPi, true);
                    }
                }
            }
            return new TreeRange(firstElement, lastElement);
        }
开发者ID:xsburg,项目名称:ReSharper.NTriples,代码行数:42,代码来源:SecretCodeFormatter.cs


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