SteamKit2.SteamID.SetFromString C# (CSharp) Method

SetFromString() public method

Sets the various components of this SteamID from a rendered form and universe.
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;
        }

Usage Example

Esempio n. 1
0
        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 );
        }
All Usage Examples Of SteamKit2.SteamID::SetFromString