AssetResolver Class
Namespace: Stride.Core.Assets.AnalysisAssembly: Stride.Core.Assets.dll
Helper to find available new asset locations and identifiers.
public sealed class AssetResolver
Name | Description | |
---|---|---|
Constructors | ||
AssetResolver() | Initializes a new instance of the AssetResolver class. |
|
AssetResolver(NamingHelper.ContainsLocationDelegate, AssetResolver.ContainsAssetWithIdDelegate) | Initializes a new instance of the AssetResolver class. |
|
Properties | ||
AlwaysCreateNewId | Gets or sets a value indicating whether to always generate a new id on RegisterId(AssetId, out AssetId). |
|
ContainsAssetWithId | Gets or sets 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. |
|
ExistingIds | Gets the asset ids already used. |
|
ExistingLocations | Gets the locations already used. |
|
Methods | ||
FromPackage(Package) | Creates a new AssetResolver using an existing package to check the existence of asset locations and ids. |
|
FromPackage(IList<Package>) | Creates a new AssetResolver using an existing package to check the existence of asset locations and ids. |
|
RegisterId(AssetId, out AssetId) | Registers an asset identifier for usage. |
|
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. |
Constructors
AssetResolver()
Initializes a new instance of the AssetResolver class.
public AssetResolver()
AssetResolver(NamingHelper.ContainsLocationDelegate, AssetResolver.ContainsAssetWithIdDelegate)
Initializes a new instance of the AssetResolver class.
public AssetResolver(NamingHelper.ContainsLocationDelegate containsLocation, AssetResolver.ContainsAssetWithIdDelegate containsAssetWithId)
Parameters
Type | Name | Description |
---|---|---|
Stride.Core.NamingHelper.ContainsLocationDelegate | containsLocation | The delegate used to check if an asset location is already used. |
AssetResolver.ContainsAssetWithIdDelegate | containsAssetWithId | 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
Type | Description |
---|---|
System.Boolean |
|
ContainsAssetWithId
Gets or sets a delegate to test if an asset id is already used.
public AssetResolver.ContainsAssetWithIdDelegate ContainsAssetWithId { get; set; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
Stride.Core.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
Type | Description |
---|---|
System.Collections.Generic.HashSet<AssetId> | The existing ids. |
ExistingLocations
Gets the locations already used.
public HashSet<string> ExistingLocations { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.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
Type | Name | Description |
---|---|---|
Package | package | The package. |
Returns
Type | Description |
---|---|
AssetResolver | A new AssetResolver. |
Exceptions
Type | Condition |
---|---|
System.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
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<Package> | packages | The packages. |
Returns
Type | Description |
---|---|
AssetResolver | A new AssetResolver. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | package |
RegisterId(AssetId, out AssetId)
Registers an asset identifier for usage.
public bool RegisterId(AssetId assetId, out AssetId newGuid)
Parameters
Type | Name | Description |
---|---|---|
AssetId | assetId | The asset identifier. |
AssetId | newGuid | The new unique identifier if an asset has already been registered with the same id. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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
Type | Name | Description |
---|---|---|
Stride.Core.IO.UFile | location | The location. |
Stride.Core.IO.UFile | newLocation | The new location. |
Returns
Type | Description |
---|---|
System.Boolean |
|