Add support for 1:many KeyValueTags

This commit is contained in:
Lothsahn 2023-08-13 23:20:47 -04:00
parent 4463739be5
commit 8afce3665f
2 changed files with 12 additions and 4 deletions

View File

@ -42,7 +42,7 @@ public Item( PublishedFileId id ) : this()
/// <summary> /// <summary>
/// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true) /// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true)
/// </summary> /// </summary>
public Dictionary<string,string> KeyValueTags { get; internal set; } public Dictionary<string,List<string>> KeyValueTags { get; internal set; }
/// <summary> /// <summary>
/// App Id of the app that created this item /// App Id of the app that created this item

View File

@ -57,12 +57,20 @@ public IEnumerable<Item> Entries
{ {
var keyValueTagsCount = SteamUGC.Internal.GetQueryUGCNumKeyValueTags( Handle, i ); var keyValueTagsCount = SteamUGC.Internal.GetQueryUGCNumKeyValueTags( Handle, i );
item.KeyValueTags = new Dictionary<string, string>( (int)keyValueTagsCount ); item.KeyValueTags = new Dictionary<string, List<string>>( (int)keyValueTagsCount );
for ( uint j = 0; j < keyValueTagsCount; j++ ) for ( uint j = 0; j < keyValueTagsCount; j++ )
{ {
string key, value; string key, value;
if ( SteamUGC.Internal.GetQueryUGCKeyValueTag( Handle, i, j, out key, out value ) ) if ( SteamUGC.Internal.GetQueryUGCKeyValueTag( Handle, i, j, out key, out value ) )
item.KeyValueTags[key] = value; {
if ( !item.KeyValueTags.TryGetValue( key, out List<string> list ) )
{
list = new List<string>();
item.KeyValueTags[key] = list;
}
list.Add(value);
}
} }
} }