Class PackageSession
A session for editing a package.
public sealed class PackageSession : IDisposable, IAssetFinder
- Inheritance
-
PackageSession
- Implements
- Extension Methods
Constructors
PackageSession()
Initializes a new instance of the PackageSession class.
public PackageSession()
PackageSession(Package)
Initializes a new instance of the PackageSession class.
public PackageSession(Package package)
Parameters
packagePackage
Fields
DefaultVisualStudioVersion
The visual studio version property used for newly created project solution files
public static readonly Version DefaultVisualStudioVersion
Field Value
Properties
AssemblyContainer
public AssemblyContainer AssemblyContainer { get; }
Property Value
- AssemblyContainer
CurrentProject
Gets or sets the selected current package.
public SolutionProject CurrentProject { get; set; }
Property Value
- SolutionProject
The selected current package.
Exceptions
- InvalidOperationException
Expecting a package that is already registered in this session
DependencyManager
Gets the dependency manager.
public AssetDependencyManager DependencyManager { get; }
Property Value
- AssetDependencyManager
AssetDependencyManager.
HasDependencyManager
Gets a value indicating whether this instance has dependency manager.
public bool HasDependencyManager { get; }
Property Value
- bool
trueif this instance has dependency manager; otherwise,false.
IsDirty
public bool IsDirty { get; set; }
Property Value
LocalPackages
Gets the user packages (excluding system packages).
public IEnumerable<Package> LocalPackages { get; }
Property Value
- IEnumerable<Package>
The user packages.
Packages
Gets the packages referenced by the solution.
public IReadOnlyPackageCollection Packages { get; }
Property Value
- IReadOnlyPackageCollection
The packages.
Projects
The projects referenced by the solution.
public ProjectCollection Projects { get; }
Property Value
SaveCompletion
Gets a task that completes when the session is finished saving.
public Task SaveCompletion { get; }
Property Value
SolutionPath
Gets or sets the solution path (sln) in case the session was loaded from a solution.
public UFile SolutionPath { get; set; }
Property Value
- UFile
The solution path.
SourceTracker
public AssetSourceTracker SourceTracker { get; }
Property Value
VisualStudioVersion
The targeted visual studio version (if specified by the loaded package)
public Version VisualStudioVersion { get; set; }
Property Value
Methods
AddExistingPackage(Package, ILogger)
Adds an existing package to the current session and runs the package analysis before adding it.
public void AddExistingPackage(Package package, ILogger logger)
Parameters
AddExistingProject(UFile, ILogger, PackageLoadParameters)
Adds an existing package to the current session.
public PackageContainer AddExistingProject(UFile projectPath, ILogger logger, PackageLoadParameters loadParametersArg = null)
Parameters
projectPathUFileThe project or package path.
loggerILoggerThe session result.
loadParametersArgPackageLoadParametersThe load parameters argument.
Returns
Exceptions
- ArgumentNullException
packagePath
- ArgumentException
Invalid relative path. Expecting an absolute package path;packagePath
- FileNotFoundException
Unable to find package
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FindAsset(AssetId)
Finds an asset by its identifier.
public AssetItem FindAsset(AssetId assetId)
Parameters
assetIdAssetIdThe identifier of the asset.
Returns
Remarks
Looks for the asset amongst all the packages of this session.
FindAsset(UFile)
Finds an asset by its location.
public AssetItem FindAsset(UFile location)
Parameters
locationUFileThe location of the asset.
Returns
Remarks
Looks for the asset amongst all the packages of this session.
FindAssetFromProxyObject(object)
Finds an asset from a proxy object.
public AssetItem FindAssetFromProxyObject(object proxyObject)
Parameters
proxyObjectobjectThe proxy object which is represent the targeted asset.
Returns
Remarks
Looks for the asset amongst all the packages of this session.
GetPackagesFromCurrent()
Gets the packages referenced by the current package.
public IEnumerable<Package> GetPackagesFromCurrent()
Returns
- IEnumerable<Package>
IEnumerable<Package>.
Load(string, PackageLoadParameters)
Loads a package from specified file path.
public static PackageSessionResult Load(string filePath, PackageLoadParameters loadParameters = null)
Parameters
filePathstringThe file path to a package file.
loadParametersPackageLoadParametersThe load parameters.
Returns
- PackageSessionResult
A package.
Exceptions
- ArgumentNullException
filePath
Load(string, PackageSessionResult, PackageLoadParameters)
Loads a package from specified file path.
public static void Load(string filePath, PackageSessionResult sessionResult, PackageLoadParameters loadParameters = null)
Parameters
filePathstringThe file path to a package file.
sessionResultPackageSessionResultThe session result.
loadParametersPackageLoadParametersThe load parameters.
Exceptions
- ArgumentNullException
filePath
- ArgumentException
File [{0}] must exist.ToFormat(filePath);filePath
LoadMissingAssets(ILogger, IEnumerable<Package>, PackageLoadParameters)
Make sure packages have their assets loaded.
public void LoadMissingAssets(ILogger log, IEnumerable<Package> packages, PackageLoadParameters loadParametersArg = null)
Parameters
logILoggerThe log.
packagesIEnumerable<Package>The packages to try to load missing assets from.
loadParametersArgPackageLoadParametersThe load parameters argument.
LoadMissingDependencies(ILogger, PackageLoadParameters)
Make sure packages have their dependencies loaded.
public void LoadMissingDependencies(ILogger log, PackageLoadParameters loadParametersArg = null)
Parameters
logILoggerThe log.
loadParametersArgPackageLoadParametersThe load parameters argument.
LoadMissingReferences(ILogger, PackageLoadParameters)
Make sure packages have their dependencies and assets loaded.
public void LoadMissingReferences(ILogger log, PackageLoadParameters loadParameters = null)
Parameters
logILoggerThe log.
loadParametersPackageLoadParametersThe load parameters.
Save(ILogger, PackageSaveParameters)
Saves all packages and assets.
public void Save(ILogger log, PackageSaveParameters saveParameters = null)
Parameters
logILoggerThe LoggerResult in which to report result.
saveParametersPackageSaveParametersThe parameters for the save operation.
UpdateAssemblyReferences(LoggerResult)
Loads the assembly references that were not loaded before.
public void UpdateAssemblyReferences(LoggerResult log)
Parameters
logLoggerResultThe log.
UpdateDependencies(SolutionProject, bool, bool)
public static void UpdateDependencies(SolutionProject project, bool directDependencies, bool flattenedDependencies)
Parameters
projectSolutionProjectdirectDependenciesboolflattenedDependenciesbool
Events
AssetDirtyChanged
public event DirtyFlagChangedDelegate<AssetItem> AssetDirtyChanged