本文整理汇总了C#中ISolution.GetLifetime方法的典型用法代码示例。如果您正苦于以下问题:C# ISolution.GetLifetime方法的具体用法?C# ISolution.GetLifetime怎么用?C# ISolution.GetLifetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISolution
的用法示例。
在下文中一共展示了ISolution.GetLifetime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Arranges the BulbItems in the correct section.
/// </summary>
/// <param name="menu">
/// The BulbMenu to add the items too.
/// </param>
////public void CreateBulbItems(BulbMenu menu)
////{
//// menu.ArrangeContextActions(this.Items);
////}
/// <summary>
/// Performs the QuickFix, inserts the configured modifier into the location specified by the violation.
/// </summary>
/// <param name="solution">
/// Current Solution.
/// </param>
/// <param name="textControl">
/// Current Text Control to modify.
/// </param>
public void Execute(ISolution solution, ITextControl textControl)
{
JetBrains.DataFlow.LifetimeDefinition definition = JetBrains.DataFlow.Lifetimes.Define(solution.GetLifetime());
JetBrains.DataFlow.Lifetime lifetime = definition.Lifetime;
try
{
unsafe
{
ChangeInspectionSeverityDialog dialog = new ChangeInspectionSeverityDialog(lifetime, this.commonIconsComponent);
IContextBoundSettingsStore contextBoundSettingsStore =
this.settingsStore.BindToContextTransient(ContextRange.Smart(textControl.Document.ToDataContext()));
HighlightingSettingsManager.ConfigurableSeverityItem item = this.highlightingSettingsManager.GetSeverityItem(this.HighlightID);
dialog.Severity = this.highlightingSettingsManager.GetConfigurableSeverity(this.HighlightID, contextBoundSettingsStore);
dialog.SeverityOptionsTitle = string.Format(item.FullTitle + ":");
dialog.CanBeError = !item.SolutionAnalysisRequired;
if (dialog.ShowDialog(User32Dll.GetForegroundWindow()) == true)
{
IContextBoundSettingsStore store = contextBoundSettingsStore;
if (dialog.SelectedSettingsLayer != null)
{
store = dialog.SelectedSettingsLayer.Model.SettingsStoreContext;
}
store.SetIndexedValue(HighlightingSettingsAccessor.InspectionSeverities, this.HighlightID, dialog.Severity);
}
}
}
finally
{
definition.Terminate();
}
}
示例2: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var unitTestSessionManager = solution.GetComponent<IUnitTestSessionManager>();
var element = solution.GetComponent<MethodRunnerProvider>().CreateElement(myClassDeclaration.GetSourceFile().GetProject(), new ClrTypeName(myClassDeclaration.CLRName), myMethodDeclaration.DeclaredName, myClassDeclaration.IsStatic, myMethodDeclaration.IsStatic);
var unitTestElementManager = solution.GetComponent<IUnitTestElementManager>();
unitTestElementManager.AddElement(element);
var sessionView = unitTestSessionManager.GetSession(SessionID) ?? unitTestSessionManager.CreateSession(id: SessionID);
sessionView.Title.Value = "Run Method " + myMethodDeclaration.DeclaredName;
sessionView.Session.AddElement(element);
var launchLifetime = Lifetimes.Define(solution.GetLifetime(), "MethodRunner");
launchLifetime.Lifetime.AddAction(() =>
{
unitTestElementManager.RemoveElements(new[] {element});
unitTestSessionManager.CloseSession(sessionView);
});
var unitTestResultManager = solution.GetComponent<IUnitTestResultManager>();
EventHandler<UnitTestResultEventArgs> onUnitTestResultUpdated = (sender, args) =>
{
if (args.Element == element && args.Result.RunStatus == UnitTestRunStatus.Completed)
{
var exceptions = string.Empty;
var resultData = unitTestResultManager.GetResultData(args.Element);
if (resultData.Exceptions.Any())
exceptions = resultData.Exceptions.First().StackTrace;
MessageBox.ShowInfo(args.Result.Message + " " + resultData.Output + " " + exceptions);
// cleanup
launchLifetime.Terminate();
}
};
unitTestResultManager.UnitTestResultUpdated += onUnitTestResultUpdated;
launchLifetime.Lifetime.AddAction(() => unitTestResultManager.UnitTestResultUpdated -= onUnitTestResultUpdated);
sessionView.Run(new UnitTestElements(new[] {element}), solution.GetComponent<ProcessHostProvider>());
Assembly.LoadFile(typeof(RunMethodTask).Assembly.Location);
return null;
}