Interface IAssetProvider
An interface that provides all the methods to fetch an IAsset.
Namespace: Unity.Cloud.Assets
Syntax
public interface IAssetProvider
Properties
Name
The name of the provider.
Declaration
string Name { get; set; }
Property Value
Type | Description |
---|---|
String |
Methods
AggregateAsync(IAssetSearchFilter, AggregationParameters, CancellationToken)
Implement this method to get a count of assets that satisfy the search criteria.
Declaration
Task<Aggregation> AggregateAsync(IAssetSearchFilter assetSearchFilter, AggregationParameters parameters, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IAssetSearchFilter | assetSearchFilter | The object containing the parameters for the asset search. |
AggregationParameters | parameters | The object containing the necessary information for aggregation. |
CancellationToken | token | The cancellation token |
Returns
Type | Description |
---|---|
Task<Aggregation> | A task whose result is a count of assets that satisfy the |
GetAssetAsync(IOrganization, IProject, String, Int32, CancellationToken)
Implement this method to get a single IAsset.
Declaration
Task<IAsset> GetAssetAsync(IOrganization organization, IProject project, string assetId, int assetVersion, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IOrganization | organization | The organization the |
IProject | project | The id of the project the |
String | assetId | The id of the asset to retrieve. |
Int32 | assetVersion | The version number of the asset. |
CancellationToken | token | The cancellation token |
Returns
Type | Description |
---|---|
Task<IAsset> | A task whose result is the requested IAsset. |
Examples
async Task<IAsset> GetAsset(IOrganization organization, IProject project, string assetId, int assetVersion, CancellationToken cancellationToken)
{
var asset = await m_AssetProvider.GetAssetAsync(organization, project, assetId, assetVersion, cancellationToken);
return asset;
}
GetAssetAsync<TAsset>(IOrganization, IProject, String, Int32, CancellationToken)
Implement this method to get a single asset of type TAsset
.
Declaration
Task<TAsset> GetAssetAsync<TAsset>(IOrganization organization, IProject project, string assetId, int assetVersion, CancellationToken token)
where TAsset : IAsset, new()
Parameters
Type | Name | Description |
---|---|---|
IOrganization | organization | The organization the |
IProject | project | The id of the project the |
String | assetId | The id of the asset to retrieve. |
Int32 | assetVersion | The version number of the asset. |
CancellationToken | token | The cancellation token |
Returns
Type | Description |
---|---|
Task<TAsset> | A task whose result is the requested IAsset. |
Type Parameters
Name | Description |
---|---|
TAsset | A type which inherits from IAsset. |
Examples
async Task<Asset> GetAsset_GenericType(IOrganization organization, IProject project, string assetId, int assetVersion, CancellationToken cancellationToken)
{
var asset = await m_AssetProvider.GetAssetAsync<Asset>(organization, project, assetId, assetVersion, cancellationToken);
return asset;
}
SearchAsync(IAssetSearchFilter, Pagination, CancellationToken)
Implement this method to get a collection of assets that satisfy the search criteria.
Declaration
Task<IAssetPage> SearchAsync(IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IAssetSearchFilter | assetSearchFilter | The object containing the parameters for the asset search. |
Pagination | pagination | An object containing the necessary information create an IAssetPage. |
CancellationToken | token | The cancellation token |
Returns
Type | Description |
---|---|
Task<IAssetPage> | A task whose result is an IAssetPage containing a collection of PageSize IAsset results. |
Examples
async Task<IAssetPage> SearchForAssets(IOrganization organization, IProject project, string assetName, CancellationToken cancellationToken)
{
var assetSearchFilter = new AssetSearchFilter(organization, project);
assetSearchFilter.Name.Include(assetName);
var pagination = new Pagination(nameof(IAsset.VersionName), 20);
var assetPage = await m_AssetProvider.SearchAsync(assetSearchFilter, pagination, cancellationToken);
return assetPage;
}
SearchAsync<TAsset>(IAssetSearchFilter, Pagination, CancellationToken)
Implement this method to get a collection of assets that satisfy the search criteria.
Declaration
Task<IAssetPage> SearchAsync<TAsset>(IAssetSearchFilter assetSearchFilter, Pagination pagination, CancellationToken token)
where TAsset : IAsset, new()
Parameters
Type | Name | Description |
---|---|---|
IAssetSearchFilter | assetSearchFilter | The object containing the parameters for the asset search. |
Pagination | pagination | An object containing the necessary information create an IAssetPage. |
CancellationToken | token | The cancellation token |
Returns
Type | Description |
---|---|
Task<IAssetPage> | A task whose result is an IAssetPage containing a collection of PageSize IAsset results. |
Type Parameters
Name | Description |
---|---|
TAsset | A type which inherits from IAsset. |
Examples
async Task<IAssetPage> SearchForAssets_GenericType(IOrganization organization, IProject project, string assetName, CancellationToken cancellationToken)
{
var assetSearchFilter = new AssetSearchFilter(organization, project);
assetSearchFilter.Name.Include(assetName);
var pagination = new Pagination(nameof(IAsset.VersionName), 20);
var assetPage = await m_AssetProvider.SearchAsync<Asset>(assetSearchFilter, pagination, cancellationToken);
return assetPage;
}