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


C# IExecutionContext.OpenFile方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:72,代码来源:ActionExecutor.cs


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