本文整理汇总了C#中IPackageRepository.StartOperation方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageRepository.StartOperation方法的具体用法?C# IPackageRepository.StartOperation怎么用?C# IPackageRepository.StartOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageRepository
的用法示例。
在下文中一共展示了IPackageRepository.StartOperation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartOperation
private IDisposable StartOperation(IPackageRepository activeRepository)
{
if (!String.IsNullOrEmpty(_operation))
{
return activeRepository.StartOperation(_operation);
}
return DisposableAction.NoOp;
}
示例2: UpdatePackages
internal void UpdatePackages(IPackageRepository localRepository,
IFileSystem sharedRepositoryFileSystem,
ISharedPackageRepository sharedPackageRepository,
IPackageRepository sourceRepository,
IPackageConstraintProvider constraintProvider,
IPackagePathResolver pathResolver,
IProjectSystem project)
{
var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);
var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
{
ConstraintProvider = constraintProvider
};
// Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
// Consequently, when querying the package reference repository, we would have package references with no backing package files in
// the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
projectManager.PackageReferenceAdded += (sender, eventArgs) =>
{
PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
};
projectManager.Logger = project.Logger = this;
foreach (var package in GetPackages(localRepository))
{
if (localRepository.Exists(package.Id))
{
using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
{
try
{
// If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
// being considered for an update.
bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
var resolver = new ActionResolver()
{
AllowPrereleaseVersions = allowPrerelease
};
var updateUtility = new UpdateUtility(resolver)
{
AllowPrereleaseVersions = allowPrerelease,
Safe = Safe
};
var operations = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
var userOperationExecutor = new ActionExecutor();
userOperationExecutor.Execute(operations);
}
catch (InvalidOperationException e)
{
if (Console.Verbosity == NuGet.Verbosity.Detailed)
{
Console.WriteWarning(e.ToString());
}
else
{
Console.WriteWarning(e.Message);
}
}
}
}
}
}
示例3: GetReferences
internal IEnumerable<PackageDependency> GetReferences(IPackageRepository localRepository,
IFileSystem sharedRepositoryFileSystem,
ISharedPackageRepository sharedPackageRepository,
IPackageRepository sourceRepository,
IPackageConstraintProvider constraintProvider,
IPackagePathResolver pathResolver,
IProjectSystem project)
{
var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);
var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
{
ConstraintProvider = constraintProvider
};
// Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
// Consequently, when querying the package reference repository, we would have package references with no backing package files in
// the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
projectManager.PackageReferenceAdded += (sender, eventArgs) =>
{
PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
};
projectManager.Logger = project.Logger = new NugetUpdateTask.VerboseLogger(this);
using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
{
foreach (var package in GetPackages(localRepository))
{
if (localRepository.Exists(package.Id))
{
if (projectManager.IsInstalled(package))
{
Log(Level.Debug, "Found installed package {0} version {1}", package.Id, package.Version);
yield return new PackageDependency(package.Id, new VersionSpec(package.Version));
}
}
}
}
}
示例4: UpdatePackages
internal void UpdatePackages(IPackageRepository localRepository,
IFileSystem sharedRepositoryFileSystem,
ISharedPackageRepository sharedPackageRepository,
IPackageRepository sourceRepository,
IPackageConstraintProvider constraintProvider,
IPackagePathResolver pathResolver,
IProjectSystem project)
{
var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);
var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
{
ConstraintProvider = constraintProvider
};
// Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
// Consequently, when querying the package reference repository, we would have package references with no backing package files in
// the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
projectManager.PackageReferenceAdded += (sender, eventArgs) =>
{
PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
};
projectManager.Logger = project.Logger = this;
using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
{
foreach (var package in GetPackages(localRepository))
{
if (localRepository.Exists(package.Id))
{
try
{
// If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
// being considered for an update.
bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
if (Safe)
{
IVersionSpec safeRange = VersionUtility.GetSafeRange(package.Version);
projectManager.UpdatePackageReference(package.Id, safeRange, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
}
else
{
projectManager.UpdatePackageReference(package.Id, version: null, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
}
}
catch (InvalidOperationException e)
{
Console.WriteWarning(e.Message);
}
}
}
}
}
示例5: UpdatePackages
internal void UpdatePackages(IPackageRepository localRepository,
IPackageRepository sourceRepository,
IPackageConstraintProvider constraintProvider,
IPackagePathResolver pathResolver,
IProjectSystem project)
{
var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
{
ConstraintProvider = constraintProvider
};
if (Verbose)
{
projectManager.Logger = Console;
}
using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
{
UpdatePackages(localRepository, projectManager);
}
}