Added SteamUGC.FetchItem

This commit is contained in:
Garry Newman 2019-05-08 09:40:28 +01:00
parent eceeb2cb8f
commit 966ad90630

View File

@ -44,5 +44,24 @@ public static bool Download( PublishedFileId fileId, bool highPriority = false )
{
return Internal.DownloadItem( fileId, highPriority );
}
/// <summary>
/// Utility function to fetch a single item. Internally this uses Ugc.FileQuery -
/// which you can use to query multiple items if you need to.
/// </summary>
public static async Task<Ugc.Item?> FetchItem( PublishedFileId fileId )
{
var result = await new Ugc.FileQuery( fileId )
.GetPageAsync( 1 );
if ( !result.HasValue || result.Value.ResultCount != 1 )
return null;
var item = result.Value.Entries.First();
result.Value.Dispose();
return item;
}
}
}