Table of Contents

Class AssetResolver

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

Helper to find available new asset locations and identifiers.

public sealed class AssetResolver
Inheritance
AssetResolver

Constructors

AssetResolver()

Initializes a new instance of the AssetResolver class.

public AssetResolver()

AssetResolver(ContainsLocationDelegate, ContainsAssetWithIdDelegate)

Initializes a new instance of the AssetResolver class.

public AssetResolver(NamingHelper.ContainsLocationDelegate containsLocation, AssetResolver.ContainsAssetWithIdDelegate containsAssetWithId)

Parameters

containsLocation NamingHelper.ContainsLocationDelegate

The delegate used to check if an asset location is already used.

containsAssetWithId AssetResolver.ContainsAssetWithIdDelegate

The delegate used to check if an asset identifier is already used.

Properties

AlwaysCreateNewId

Gets or sets a value indicating whether to always generate a new id on RegisterId(AssetId, out AssetId).

public bool AlwaysCreateNewId { get; set; }

Property Value

bool

true if [force new identifier]; otherwise, false.

ContainsAssetWithId

Gets or sets a delegate to test if an asset id is already used.

public AssetResolver.ContainsAssetWithIdDelegate ContainsAssetWithId { get; set; }

Property Value

AssetResolver.ContainsAssetWithIdDelegate

A delegate to test if an asset id is already used.

ContainsLocation

Gets or sets a delegate to test if a location is already used.

public NamingHelper.ContainsLocationDelegate ContainsLocation { get; set; }

Property Value

NamingHelper.ContainsLocationDelegate

A delegate to test if a location is already used.

ExistingIds

Gets the asset ids already used.

public HashSet<AssetId> ExistingIds { get; }

Property Value

HashSet<AssetId>

The existing ids.

ExistingLocations

Gets the locations already used.

public HashSet<string> ExistingLocations { get; }

Property Value

HashSet<string>

The locations.

Methods

FromPackage(Package)

Creates a new AssetResolver using an existing package to check the existence of asset locations and ids.

public static AssetResolver FromPackage(Package package)

Parameters

package Package

The package.

Returns

AssetResolver

A new AssetResolver.

Exceptions

ArgumentNullException

package

FromPackage(IList<Package>)

Creates a new AssetResolver using an existing package to check the existence of asset locations and ids.

public static AssetResolver FromPackage(IList<Package> packages)

Parameters

packages IList<Package>

The packages.

Returns

AssetResolver

A new AssetResolver.

Exceptions

ArgumentNullException

package

RegisterId(AssetId, out AssetId)

Registers an asset identifier for usage.

public bool RegisterId(AssetId assetId, out AssetId newGuid)

Parameters

assetId AssetId

The asset identifier.

newGuid AssetId

The new unique identifier if an asset has already been registered with the same id.

Returns

bool

true if the asset id is already in used. newGuid contains a new guid, false otherwise.

RegisterLocation(UFile, out UFile)

Finds a name available for a new asset. This method will try to create a name based on an existing name and will append "_" + (number++) on every try. The new location found is added to the known existing locations.

public bool RegisterLocation(UFile location, out UFile newLocation)

Parameters

location UFile

The location.

newLocation UFile

The new location.

Returns

bool

true if there is a new location, false otherwise.