public SetFromString ( string steamId, EUniverse eUniverse ) : bool | ||
steamId | string | A "STEAM_" rendered form of the SteamID. |
eUniverse | EUniverse | The universe the SteamID belongs to. |
return | bool |
public bool SetFromString( string steamId, EUniverse eUniverse )
{
if ( string.IsNullOrEmpty( steamId ) )
return false;
Match m = SteamIDRegex.Match( steamId );
if ( !m.Success )
return false;
uint accId = uint.Parse( m.Groups[ "accountid" ].Value );
uint authServer = uint.Parse( m.Groups[ "authserver" ].Value );
this.AccountUniverse = eUniverse;
this.AccountInstance = 1;
this.AccountType = EAccountType.Individual;
this.AccountID = ( accId << 1 ) | authServer;
return true;
}
public void SetFromStringHandlesInvalid() { SteamID sid = new SteamID(); bool setFromNullString = sid.SetFromString( null, EUniverse.Public ); Assert.False( setFromNullString ); bool setFromEmptyString = sid.SetFromString( "", EUniverse.Public ); Assert.False( setFromEmptyString ); bool setFromInvalidString = sid.SetFromString( "NOT A STEAMID!", EUniverse.Public ); Assert.False( setFromInvalidString ); bool setFromInvalidAccountId = sid.SetFromString( "STEAM_0:1:999999999999999999999999999999", EUniverse.Public ); Assert.False( setFromInvalidAccountId ); }