Table of Contents

Class PackageAssetCollection

Namespace
Stride.Core.Assets
Assembly
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
Inheritance
PackageAssetCollection
Implements
Extension Methods

Constructors

PackageAssetCollection(Package)

Initializes a new instance of the PackageAssetCollection class.

public PackageAssetCollection(Package package)

Parameters

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

int

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

bool

true if this instance is dirty; otherwise, false.

IsReadOnly

Gets a value indicating whether this collection is read-only. Default is false.

public bool IsReadOnly { get; }

Property Value

bool

false

Package

Gets the package this collection is attached to.

public Package Package { get; }

Property Value

Package

The package.

Methods

Add(AssetItem)

Adds an AssetItem to this instance.

public void Add(AssetItem item)

Parameters

item AssetItem

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

item AssetItem

The item.

Exceptions

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

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

assetItem AssetItem

The asset item.

Returns

bool

Exceptions

ArgumentNullException

assetItem

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

assetId AssetId

The asset identifier.

Returns

bool

true if this instance contains an asset with the specified identifier; otherwise, false.

CopyTo(AssetItem[], int)

Copies items to the specified array.

public void CopyTo(AssetItem[] array, int arrayIndex)

Parameters

array AssetItem[]

The array.

arrayIndex int

Index of the array.

Find(AssetId)

Finds an asset by its location.

public AssetItem Find(AssetId assetId)

Parameters

assetId AssetId

The asset unique identifier.

Returns

AssetItem

AssetItem.

Find(string)

Finds an asset by its location.

public AssetItem Find(string location)

Parameters

location string

The location of the assets.

Returns

AssetItem

AssetItem.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<AssetItem> GetEnumerator()

Returns

IEnumerator<AssetItem>

An enumerator that can be used to iterate through the collection.

Remove(AssetItem)

Removes an AssetItem from this instance.

public bool Remove(AssetItem item)

Parameters

item AssetItem

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

RemoveById(AssetId)

Removes an AssetItem from this instance.

public bool RemoveById(AssetId itemId)

Parameters

itemId AssetId

The item identifier.

Returns

bool

true if itemId was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

ResumeCollectionChanged()

Resumes the collection changed that happened on this collection and fire a 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

NotifyCollectionChangedEventHandler