本文整理汇总了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");
}
}
}
}
}
示例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);
}