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
Example #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 );
        }
Example #2
0
        private void btnOK_Click( object sender, EventArgs e )
        {
            SteamID steamId = new SteamID();
            steamId.SetFromString( txtFriend.Text, Steam3.SteamClient.ConnectedUniverse );

            if ( steamId.IsValid )
            {
                Steam3.SteamFriends.AddFriend( steamId );
            }
            else
            {
                Steam3.SteamFriends.AddFriend( txtFriend.Text );
            }

            this.Close();
        }
        private static bool TrySetSteamID(string input, out SteamID steamID)
        {
            steamID = new SteamID();

            if (steamID.SetFromString(input, EUniverse.Public)
            ||  steamID.SetFromSteam3String(input))
            {
                return true;
            }

            ulong numericInput;

            if (ulong.TryParse(input, out numericInput))
            {
                steamID.SetFromUInt64(numericInput);

                return true;
            }

            return false;
        }