Table of Contents

Class PackageSession

Namespace
Stride.Core.Assets
Assembly
Stride.Core.Assets.dll

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

package Package

Fields

DefaultVisualStudioVersion

The visual studio version property used for newly created project solution files

public static readonly Version DefaultVisualStudioVersion

Field Value

Version

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

true if this instance has dependency manager; otherwise, false.

IsDirty

public bool IsDirty { get; set; }

Property Value

bool

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

ProjectCollection

SaveCompletion

Gets a task that completes when the session is finished saving.

public Task SaveCompletion { get; }

Property Value

Task

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

AssetSourceTracker

VisualStudioVersion

The targeted visual studio version (if specified by the loaded package)

public Version VisualStudioVersion { get; set; }

Property Value

Version

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

package Package

The package to add

logger ILogger

The logger

AddExistingProject(UFile, ILogger, PackageLoadParameters)

Adds an existing package to the current session.

public PackageContainer AddExistingProject(UFile projectPath, ILogger logger, PackageLoadParameters loadParametersArg = null)

Parameters

projectPath UFile

The project or package path.

logger ILogger

The session result.

loadParametersArg PackageLoadParameters

The load parameters argument.

Returns

PackageContainer

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

assetId AssetId

The identifier of the asset.

Returns

AssetItem

The corresponding AssetItem if found; otherwise, null.

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

location UFile

The location of the asset.

Returns

AssetItem

The corresponding AssetItem if found; otherwise, null.

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

proxyObject object

The proxy object which is represent the targeted asset.

Returns

AssetItem

The corresponding AssetItem if found; otherwise, null.

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

filePath string

The file path to a package file.

loadParameters PackageLoadParameters

The 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

filePath string

The file path to a package file.

sessionResult PackageSessionResult

The session result.

loadParameters PackageLoadParameters

The 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

log ILogger

The log.

packages IEnumerable<Package>

The packages to try to load missing assets from.

loadParametersArg PackageLoadParameters

The load parameters argument.

LoadMissingDependencies(ILogger, PackageLoadParameters)

Make sure packages have their dependencies loaded.

public void LoadMissingDependencies(ILogger log, PackageLoadParameters loadParametersArg = null)

Parameters

log ILogger

The log.

loadParametersArg PackageLoadParameters

The load parameters argument.

LoadMissingReferences(ILogger, PackageLoadParameters)

Make sure packages have their dependencies and assets loaded.

public void LoadMissingReferences(ILogger log, PackageLoadParameters loadParameters = null)

Parameters

log ILogger

The log.

loadParameters PackageLoadParameters

The load parameters.

Save(ILogger, PackageSaveParameters)

Saves all packages and assets.

public void Save(ILogger log, PackageSaveParameters saveParameters = null)

Parameters

log ILogger

The LoggerResult in which to report result.

saveParameters PackageSaveParameters

The parameters for the save operation.

UpdateAssemblyReferences(LoggerResult)

Loads the assembly references that were not loaded before.

public void UpdateAssemblyReferences(LoggerResult log)

Parameters

log LoggerResult

The log.

UpdateDependencies(SolutionProject, bool, bool)

public static void UpdateDependencies(SolutionProject project, bool directDependencies, bool flattenedDependencies)

Parameters

project SolutionProject
directDependencies bool
flattenedDependencies bool

Events

AssetDirtyChanged

public event DirtyFlagChangedDelegate<AssetItem> AssetDirtyChanged

Event Type

DirtyFlagChangedDelegate<AssetItem>