PackageAssetCollection Class
Namespace: Stride.Core.AssetsAssembly: Stride.Core.Assets.dll
A collection of AssetItem that contains only absolute location without any drive information. This class cannot be inherited.
public sealed class PackageAssetCollection : ICollection<AssetItem>, IReadOnlyCollection<AssetItem>, IEnumerable<AssetItem>, ICollection, IEnumerable, INotifyCollectionChanged
Name | Description | |
---|---|---|
Constructors | ||
PackageAssetCollection(Package) | Initializes a new instance of the PackageAssetCollection class. |
|
Properties | ||
Count | Gets the number of elements contained in this instance. |
|
IsDirty | Gets or sets a value indicating whether this instance is dirty. Sets this flag when moving assets between packages or removing assets. |
|
IsReadOnly | Gets a value indicating whether this collection is read-only. Default is false. |
|
Package | Gets the package this collection is attached to. |
|
Methods | ||
Add(AssetItem) | Adds an AssetItem to this instance. |
|
CheckCanAdd(AssetItem) | Checks if the specified item can be add to this collection. |
|
Clear() | Removes all items from this instance. |
|
Contains(AssetItem) | Checks this collection contains the specified asset reference, throws an exception if not found. |
|
ContainsById(AssetId) | Determines whether this instance contains an asset with the specified identifier. |
|
CopyTo(AssetItem[], Int32) | Copies items to the specified array. |
|
Find(AssetId) | Finds an asset by its location. |
|
Find(String) | Finds an asset by its location. |
|
GetEnumerator() | ||
Remove(AssetItem) | Removes an AssetItem from this instance. |
|
RemoveById(AssetId) | Removes an AssetItem from this instance. |
|
ResumeCollectionChanged() | Resumes the collection changed that happened on this collection and fire a System.Collections.Specialized.NotifyCollectionChangedAction.Reset |
|
SuspendCollectionChanged() | Suspends the collection changed that can happen on this collection. |
|
Events | ||
CollectionChanged | Occurs when the collection changes. |
|
Explicit Interface Implementations | ||
ICollection.CopyTo(Array, Int32) | ||
ICollection.IsSynchronized | ||
ICollection.SyncRoot | ||
IEnumerable.GetEnumerator() |
Constructors
PackageAssetCollection(Package)
Initializes a new instance of the PackageAssetCollection class.
public PackageAssetCollection(Package package)
Parameters
Type | Name | Description |
---|---|---|
Package | package | The package that will contain assets. |
Properties
Count
Gets the number of elements contained in this instance.
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of elements contained in this instance. |
IsDirty
Gets or sets a value indicating whether this instance is dirty. Sets this flag when moving assets between packages or removing assets.
public bool IsDirty { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsReadOnly
Gets a value indicating whether this collection is read-only. Default is false.
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | false |
Package
Gets the package this collection is attached to.
public Package Package { get; }
Property Value
Type | Description |
---|---|
Package | The package. |
Methods
Add(AssetItem)
Adds an AssetItem to this instance.
public void Add(AssetItem item)
Parameters
Type | Name | Description |
---|---|---|
AssetItem | item | The item to add to this instance. |
CheckCanAdd(AssetItem)
Checks if the specified item can be add to this collection.
public void CheckCanAdd(AssetItem item)
Parameters
Type | Name | Description |
---|---|---|
AssetItem | item | The item. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | item;Cannot add an empty asset item reference or item;Cannot add an item with an empty asset or item;Cannot add an asset with an empty Id or item;Location cannot be null when adding an asset reference |
System.ArgumentException | An asset with the same location is already registered [{0}].ToFormat(location.Path);item or An asset with the same id [{0}] is already registered with the location [{1}].ToFormat(item.Id, location.Path);item or Asset location [{0}] cannot contain drive information.ToFormat(location);item or Asset location [{0}] must be relative and not absolute (not start with '/').ToFormat(location);item or Asset location [{0}] cannot start with relative '..'.ToFormat(location);item |
Clear()
Removes all items from this instance.
public void Clear()
Contains(AssetItem)
Checks this collection contains the specified asset reference, throws an exception if not found.
public bool Contains(AssetItem assetItem)
Parameters
Type | Name | Description |
---|---|---|
AssetItem | assetItem | The asset item. |
Returns
Type | Description |
---|---|
System.Boolean |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | assetItem |
System.Collections.Generic.KeyNotFoundException | Asset [{0}] was not found.ToFormat(assetItem) |
ContainsById(AssetId)
Determines whether this instance contains an asset with the specified identifier.
public bool ContainsById(AssetId assetId)
Parameters
Type | Name | Description |
---|---|---|
AssetId | assetId | The asset identifier. |
Returns
Type | Description |
---|---|
System.Boolean |
|
CopyTo(AssetItem[], Int32)
Copies items to the specified array.
public void CopyTo(AssetItem[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
AssetItem[] | array | The array. |
System.Int32 | arrayIndex | Index of the array. |
Find(AssetId)
Finds an asset by its location.
public AssetItem Find(AssetId assetId)
Parameters
Type | Name | Description |
---|---|---|
AssetId | assetId | The asset unique identifier. |
Returns
Type | Description |
---|---|
AssetItem | AssetItem. |
Find(String)
Finds an asset by its location.
public AssetItem Find(string location)
Parameters
Type | Name | Description |
---|---|---|
System.String | location | The location of the assets. |
Returns
Type | Description |
---|---|
AssetItem | AssetItem. |
GetEnumerator()
public IEnumerator<AssetItem> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<AssetItem> |
Remove(AssetItem)
Removes an AssetItem from this instance.
public bool Remove(AssetItem item)
Parameters
Type | Name | Description |
---|---|---|
AssetItem | item | The object to remove from the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
RemoveById(AssetId)
Removes an AssetItem from this instance.
public bool RemoveById(AssetId itemId)
Parameters
Type | Name | Description |
---|---|---|
AssetId | itemId | The item identifier. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
ResumeCollectionChanged()
Resumes the collection changed that happened on this collection and fire a System.Collections.Specialized.NotifyCollectionChangedAction.Reset
public void ResumeCollectionChanged()
SuspendCollectionChanged()
Suspends the collection changed that can happen on this collection.
public void SuspendCollectionChanged()
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Type | Description |
---|---|
System.Collections.Specialized.NotifyCollectionChangedEventHandler |
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32)
void ICollection.CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Array | array | |
System.Int32 | index |
ICollection.IsSynchronized
bool ICollection.IsSynchronized { get; }
Returns
Type | Description |
---|---|
System.Boolean |
ICollection.SyncRoot
object ICollection.SyncRoot { get; }
Returns
Type | Description |
---|---|
System.Object |
IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |