本文整理汇总了C#中IExecutionContext.OpenFile方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.OpenFile方法的具体用法?C# IExecutionContext.OpenFile怎么用?C# IExecutionContext.OpenFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExecutionContext
的用法示例。
在下文中一共展示了IExecutionContext.OpenFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteActions
public void ExecuteActions(
IEnumerable<NewPackageAction> actions,
IExecutionContext context,
UserAction userAction = null)
{
// Capture actions we've already done so we can roll them back in case of an error
var executedActions = new List<NewPackageAction>();
_userAction = userAction;
ExceptionDispatchInfo capturedException = null;
try
{
_readmeFilePath = null;
foreach (var action in actions)
{
IActionHandler handler;
if (!_actionHandlers.TryGetValue(action.ActionType, out handler))
{
NuGetTraceSources.ActionExecutor.Error(
"execute/unhandledaction",
"[{0}] Skipping unknown action: {1}",
action.PackageIdentity,
action.ToString());
}
else
{
NuGetTraceSources.ActionExecutor.Info(
"execute/executing",
"[{0}] Executing action: {1}",
action.PackageIdentity,
action.ToString());
handler.Execute(action, context, CancellationToken.None);
executedActions.Add(action);
}
// Add binding redirects when neccessary.
// Note that the current implementation is kind of inefficient.
// AddBindingRedirects is run every time after an install or uninstall,
// so it's called multiple times if multiple packages are installed/uninstalled.
// But in fact, it's only needed to be called per project
// once after all packages are installed uninstalled.
var packageManager = action.Target.TryGetFeature<IPackageManager>();
var projectManager = action.Target.TryGetFeature<IProjectManager>();
if (packageManager != null &&
projectManager != null &&
packageManager.BindingRedirectEnabled &&
projectManager.Project.IsBindingRedirectSupported)
{
packageManager.AddBindingRedirects(projectManager);
}
UpdateReadmeFilePath(action);
}
if (_readmeFilePath != null)
{
context.OpenFile(_readmeFilePath);
}
}
catch (Exception ex)
{
capturedException = ExceptionDispatchInfo.Capture(ex);
}
if (capturedException != null)
{
// Roll back the actions and rethrow
Rollback(executedActions, context);
capturedException.Throw();
}
}