本文整理汇总了C#中IVsPackageManager.IsProjectLevel方法的典型用法代码示例。如果您正苦于以下问题:C# IVsPackageManager.IsProjectLevel方法的具体用法?C# IVsPackageManager.IsProjectLevel怎么用?C# IVsPackageManager.IsProjectLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsPackageManager
的用法示例。
在下文中一共展示了IVsPackageManager.IsProjectLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCore
protected override bool ExecuteCore(PackageItem item)
{
_activePackageManager = GetActivePackageManager();
using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Install, item.Id, item.Version))
{
IList<Project> selectedProjectsList;
ShowProgressWindow();
bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity);
if (isProjectLevel)
{
HideProgressWindow();
var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow(
Resources.Dialog_OnlineSolutionInstruction,
item.PackageIdentity,
DetermineProjectCheckState,
ignored => true);
if (selectedProjects == null)
{
// user presses Cancel button on the Solution dialog
return false;
}
selectedProjectsList = selectedProjects.ToList();
if (selectedProjectsList.Count == 0)
{
return false;
}
// save the checked state of projects so that we can restore them the next time
SaveProjectCheckStates(selectedProjectsList);
ShowProgressWindow();
}
else
{
// solution package. just install into the solution
selectedProjectsList = new Project[0];
}
IList<PackageOperation> operations;
bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations)
: ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations);
if (!acceptLicense)
{
return false;
}
try
{
RegisterPackageOperationEvents(_activePackageManager, null);
_activePackageManager.InstallPackage(
selectedProjectsList,
item.PackageIdentity,
operations,
ignoreDependencies: false,
allowPrereleaseVersions: IncludePrerelease,
logger: this,
eventListener: this);
}
finally
{
UnregisterPackageOperationEvents(_activePackageManager, null);
}
return true;
}
}
示例2: ExecuteCore
protected override bool ExecuteCore(PackageItem item)
{
_activePackageManager = GetActivePackageManager();
using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update))
{
ShowProgressWindow();
IList<Project> selectedProjectsList;
bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity);
if (isProjectLevel)
{
HideProgressWindow();
var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow(
Resources.Dialog_UpdatesSolutionInstruction,
item.PackageIdentity,
// Selector function to return the initial checkbox state for a Project.
// We check a project if it has the current package installed by Id, but not version
project => _activePackageManager.GetProjectManager(project).LocalRepository.Exists(item.Id),
project =>
{
var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository;
// for the Updates solution dialog, we only enable a project if it has an old version of
// the package installed.
return localRepository.Exists(item.Id) &&
!localRepository.Exists(item.Id, item.PackageIdentity.Version);
}
);
if (selectedProjects == null)
{
// user presses Cancel button on the Solution dialog
return false;
}
selectedProjectsList = selectedProjects.ToList();
if (selectedProjectsList.Count == 0)
{
return false;
}
ShowProgressWindow();
}
else
{
// solution package. just update into the solution
selectedProjectsList = new Project[0];
}
IList<PackageOperation> operations;
bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations)
: ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations);
if (!acceptLicense)
{
return false;
}
if (!isProjectLevel && operations.Any())
{
// When dealing with solution level packages, only the set of actions specified under operations are executed.
// In such a case, no operation to uninstall the current package is specified. We'll identify the package that is being updated and
// explicitly add a uninstall operation.
var packageToUpdate = _activePackageManager.LocalRepository.FindPackage(item.Id);
if (packageToUpdate != null)
{
operations.Insert(0, new PackageOperation(packageToUpdate, PackageAction.Uninstall));
}
}
try
{
RegisterPackageOperationEvents(_activePackageManager, null);
_activePackageManager.UpdatePackage(
selectedProjectsList,
item.PackageIdentity,
operations,
updateDependencies: true,
allowPrereleaseVersions: IncludePrerelease,
logger: this,
eventListener: this);
}
finally
{
UnregisterPackageOperationEvents(_activePackageManager, null);
}
return true;
}
}
示例3: ExecuteCore
protected override bool ExecuteCore(PackageItem item)
{
_activePackageManager = GetActivePackageManager();
ShowProgressWindow();
IList<Project> selectedProjectsList;
if (_activePackageManager.IsProjectLevel(item.PackageIdentity))
{
HideProgressWindow();
var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow(
Resources.Dialog_UpdatesSolutionInstruction,
item.PackageIdentity,
// Selector function to return the initial checkbox state for a Project.
// We check a project if it has the current package installed by Id, but not version
project => _activePackageManager.GetProjectManager(project).LocalRepository.Exists(item.Id),
project =>
{
var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository;
// for the Updates solution dialog, we only enable a project if it has a old version of
// the package installed.
return localRepository.Exists(item.Id) &&
!localRepository.Exists(item.Id, item.PackageIdentity.Version);
}
);
if (selectedProjects == null)
{
// user presses Cancel button on the Solution dialog
return false;
}
selectedProjectsList = selectedProjects.ToList();
if (selectedProjectsList.Count == 0)
{
return false;
}
}
else
{
// solution package. just update into the solution
selectedProjectsList = new Project[0];
}
IList<PackageOperation> operations;
bool acceptLicense = CheckPSScriptAndShowLicenseAgreement(item, _activePackageManager, out operations);
if (!acceptLicense)
{
return false;
}
try
{
RegisterPackageOperationEvents(_activePackageManager, null);
_activePackageManager.UpdatePackage(
selectedProjectsList,
item.PackageIdentity,
operations,
updateDependencies: true,
allowPrereleaseVersions: false,
logger: this,
eventListener: this);
}
finally
{
UnregisterPackageOperationEvents(_activePackageManager, null);
}
return true;
}
示例4: ExecuteCore
protected override bool ExecuteCore(PackageItem item)
{
_activePackageManager = GetActivePackageManager();
using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Install, item.Id, item.Version))
{
IList<Project> selectedProjectsList;
ShowProgressWindow();
bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity);
if (isProjectLevel)
{
HideProgressWindow();
var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow(
Resources.Dialog_OnlineSolutionInstruction,
item.PackageIdentity,
DetermineProjectCheckState,
ignored => true);
if (selectedProjects == null)
{
// user presses Cancel button on the Solution dialog
return false;
}
selectedProjectsList = selectedProjects.ToList();
if (selectedProjectsList.Count == 0)
{
return false;
}
// save the checked state of projects so that we can restore them the next time
SaveProjectCheckStates(selectedProjectsList);
ShowProgressWindow();
}
else
{
// solution package. just install into the active project.
selectedProjectsList = new Project[] { _solutionManager.DefaultProject };
}
// resolve operations
var actions = ResolveActionsForInstall(
item.PackageIdentity,
_activePackageManager,
selectedProjectsList);
bool acceptLicense = ShowLicenseAgreement(actions);
if (!acceptLicense)
{
return false;
}
// execute operations
try
{
RegisterPackageOperationEvents(_activePackageManager, null);
var userOperationExecutor = new Resolver.ActionExecutor()
{
Logger = this,
PackageOperationEventListener = this
};
userOperationExecutor.Execute(actions);
}
finally
{
UnregisterPackageOperationEvents(_activePackageManager, null);
}
return true;
}
}
示例5: ExecuteCore
protected override bool ExecuteCore(PackageItem item)
{
_activePackageManager = GetActivePackageManager();
using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update, item.Id, item.Version))
{
ShowProgressWindow();
IList<Project> selectedProjectsList;
bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity);
if (isProjectLevel)
{
HideProgressWindow();
var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow(
Resources.Dialog_UpdatesSolutionInstruction,
item.PackageIdentity,
// Selector function to return the initial checkbox state for a Project.
// We check a project if it has the current package installed by Id, but not version
project =>
{
var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository;
return localRepository.Exists(item.Id) && IsVersionConstraintSatisfied(item, localRepository);
},
project =>
{
var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository;
// for the Updates solution dialog, we only enable a project if it has an old version of
// the package installed.
return localRepository.Exists(item.Id) &&
!localRepository.Exists(item.Id, item.PackageIdentity.Version) &&
IsVersionConstraintSatisfied(item, localRepository);
}
);
if (selectedProjects == null)
{
// user presses Cancel button on the Solution dialog
return false;
}
selectedProjectsList = selectedProjects.ToList();
if (selectedProjectsList.Count == 0)
{
return false;
}
ShowProgressWindow();
}
else
{
// solution package. just install into the active project.
selectedProjectsList = new Project[] { _solutionManager.DefaultProject };
}
// resolve operations
var actionsByProject = ResolveActionsByProjectForInstall(
item.PackageIdentity,
_activePackageManager,
selectedProjectsList);
// ask for license agreement
var allActions = new List<Resolver.PackageAction>();
foreach (var actions in actionsByProject.Values)
{
allActions.AddRange(actions);
}
bool acceptLicense = ShowLicenseAgreement(allActions);
if (!acceptLicense)
{
return false;
}
var actionExecutor = new Resolver.ActionExecutor();
actionExecutor.Logger = this;
actionExecutor.PackageOperationEventListener = this;
actionExecutor.CatchProjectOperationException = true;
// execute operations by project
foreach (var actionsForOneProject in actionsByProject)
{
var projectManager = actionsForOneProject.Key;
var project = ((VsProjectSystem)(projectManager.Project)).Project;
try
{
RegisterPackageOperationEvents(_activePackageManager, projectManager);
actionExecutor.Execute(actionsForOneProject.Value);
}
catch (Exception ex)
{
AddFailedProject(project, ex);
}
finally
{
UnregisterPackageOperationEvents(_activePackageManager, projectManager);
}
}
return true;
}
}