Exceptions and expression body definition

Added exception throwing for FilterStringKeyValue, changed MaxLobbyKeyLength to internal and expression body definition
This commit is contained in:
thesupersoup 2019-06-24 01:35:33 -07:00
parent 645e7bd91e
commit fdc5b49587
2 changed files with 7 additions and 4 deletions

View File

@ -12,12 +12,10 @@ namespace Steamworks
/// </summary>
public static class SteamMatchmaking
{
internal const int k_nMaxLobbyKeyLength = 255;
/// <summary>
/// Maximum number of characters a lobby metadata key can be
/// </summary>
public static int MaxLobbyKeyLength { get { return k_nMaxLobbyKeyLength; } }
internal static int MaxLobbyKeyLength => 255;
static ISteamMatchmaking _internal;

View File

@ -51,7 +51,10 @@ public LobbyQuery FilterDistanceWorldwide()
/// </summary>
public LobbyQuery FilterStringKeyValue( string nKey, string nValue )
{
if ( !string.IsNullOrEmpty(nKey) && nKey.Length <= SteamMatchmaking.MaxLobbyKeyLength )
if ( string.IsNullOrEmpty( nKey ) )
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) );
if ( nKey.Length <= SteamMatchmaking.MaxLobbyKeyLength )
{
stringFilter = new MatchMakingKeyValuePair_t
{
@ -59,6 +62,8 @@ public LobbyQuery FilterStringKeyValue( string nKey, string nValue )
Value = nValue
};
}
else
throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) );
return this;
}