Anvil
Anvil.API.StringExtensions Class Reference

Static Public Member Functions

static void AppendColored (this StringBuilder stringBuilder, string text, Color color)
 
static string ColorString (this string input, Color color)
 
static bool IsReservedScriptName (this string scriptName)
 
static bool IsValidScriptName (this string? scriptName, bool allowEmpty)
 
static float ParseFloat (this string floatString)
 
static float ParseFloat (this string floatString, float defaultValue)
 Parses the specified string as an float. More...
 
static int ParseInt (this string intString)
 
static int ParseInt (this string intString, int defaultValue)
 Parses the specified string as an integer. More...
 
static bool ParseIntBool (this string intBoolString)
 
static bool ParseIntBool (this string intBoolString, bool defaultValue)
 Parses the specified string as an integer based boolean (1 = true, 0 = false). More...
 
static ? NwObject ParseObject (this string objectIdString)
 Resolves the specified GameObject ID string to an object.
This is the temporary ID created from NwObject.ToString. See GuidExtensions.ToNwObject to parse persistent UUIDs. More...
 
static ? T ParseObject< T > (this string objectIdString)
 
static string ReadBlock (this StringReader stringReader, int length)
 
static string ReadUntilChar (this StringReader stringReader, char character)
 
static void Skip (this StringReader stringReader, int count)
 
static string StripColors (this string input)
 Strip any color codes from a string. More...
 
static string ToBase64EncodedString (this byte[] data)
 
static byte[] ToByteArray (this string base64String)
 
static bool TryParseFloat (this string floatString, out float result)
 
static bool TryParseInt (this string intString, out int result)
 
static bool TryParseIntBool (this string intBoolString, out bool result)
 
static bool TryParseObject (this string objectIdString, [NotNullWhen(true)] out NwObject? result)
 Tries to resolve the specified GameObject ID string to an object. A return value indicates whether the conversion succeeded or failed.
This is the temporary ID created from NwObject.ToString. See GuidExtensions.ToNwObject to parse persistent UUIDs. More...
 
static bool TryParseObject< T > (this string objectIdString, [NotNullWhen(true)] out T? result)
 

Member Function Documentation

◆ ParseFloat()

static float Anvil.API.StringExtensions.ParseFloat ( this string  floatString,
float  defaultValue 
)
inlinestatic

Parses the specified string as an float.

Parameters
floatStringThe float string to parse.
defaultValueIf parsing fails, the value to return instead.

◆ ParseInt()

static int Anvil.API.StringExtensions.ParseInt ( this string  intString,
int  defaultValue 
)
inlinestatic

Parses the specified string as an integer.

Parameters
intStringThe integer string to parse.
defaultValueIf parsing fails, the value to return instead.

◆ ParseIntBool()

static bool Anvil.API.StringExtensions.ParseIntBool ( this string  intBoolString,
bool  defaultValue 
)
inlinestatic

Parses the specified string as an integer based boolean (1 = true, 0 = false).

Parameters
intBoolStringThe integer string to parse.
defaultValueIf parsing fails, the value to return instead.

◆ ParseObject()

static ? NwObject Anvil.API.StringExtensions.ParseObject ( this string  objectIdString)
inlinestatic

Resolves the specified GameObject ID string to an object.
This is the temporary ID created from NwObject.ToString. See GuidExtensions.ToNwObject to parse persistent UUIDs.

Parameters
objectIdStringThe object ID string to parse.
Returns
The NwObject associated with the specified object ID.

◆ StripColors()

static string Anvil.API.StringExtensions.StripColors ( this string  input)
inlinestatic

Strip any color codes from a string.

Parameters
inputThe string to strip of color.
Returns
The new string without any color codes.

◆ TryParseObject()

static bool Anvil.API.StringExtensions.TryParseObject ( this string  objectIdString,
[NotNullWhen(true)] out NwObject result 
)
inlinestatic

Tries to resolve the specified GameObject ID string to an object. A return value indicates whether the conversion succeeded or failed.
This is the temporary ID created from NwObject.ToString. See GuidExtensions.ToNwObject to parse persistent UUIDs.

Parameters
objectIdStringThe object ID string to parse.
resultWhen this method returns, contains the object referenced by the number contained in objectIdString, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or System.String.Empty, is not in a format compliant with style, or represents an invalid object reference.
Returns
true if objectIdString was converted successfully; otherwise, false.

The documentation for this class was generated from the following file: