Class Parsers
Definition
Namespace: StardewUI
Assembly: StardewUI.dll
Utilities for parsing third-party types, generally related to MonoGame/XNA.
Inheritance
Object ⇦ Parsers
Members
Methods
Name | Description |
---|---|
ParseColor(string) | Parses a named or hex color as a Color. |
ParseRectangle(string) | Parses a Rectangle value from its comma-separated string representation. |
ParseVector2(string) | Parses a Vector2 from a comma-separated value pair. |
ParseVector2(ReadOnlySpan<Char>) | Parses a Vector2 from a comma-separated value pair. |
TryParseColor(string, Color) | Attempts to parse a named or hex color as a Color. |
TryParseVector2(ReadOnlySpan<Char>, Vector2) | Attempts to parse a Vector2 from a comma-separated value pair. |
Details
Methods
ParseColor(string)
Parses a named or hex color as a Color.
Parameters
value
string
A string containing a named or hex color.a
Returns
The parsed color.
Remarks
Supports hex strings of the form #rgb
, #rrggbb
, or #rrggbbaa
, as well as any of the MonoGame named color strings like LimeGreen
.
ParseRectangle(string)
Parses a Rectangle value from its comma-separated string representation.
Parameters
value
string
String representation of a Rectangle, having 4 comma-separated integer values.
Returns
The parsed Rectangle.
Remarks
This is equivalent to Convert but does not require an instance.
ParseVector2(string)
Parses a Vector2 from a comma-separated value pair.
Parameters
value
string
The string value.
Returns
The parsed Vector2.
ParseVector2(ReadOnlySpan<Char>)
Parses a Vector2 from a comma-separated value pair.
Parameters
value
ReadOnlySpan<Char>
The string value.
Returns
The parsed Vector2.
TryParseColor(string, Color)
Attempts to parse a named or hex color as a Color.
Parameters
value
string
A string containing a named or hex color.a
color
Color
The result if successful, otherwise a default Color.
Returns
true
if the value
was successfully parsed into color
; false
if the parsing was unsuccessful.
Remarks
Supports hex strings of the form #rgb
, #rrggbb
, or #rrggbbaa
, as well as any of the MonoGame named color strings like LimeGreen
.
TryParseVector2(ReadOnlySpan<Char>, Vector2)
Attempts to parse a Vector2 from a comma-separated value pair.
public static bool TryParseVector2(ReadOnlySpan<System.Char> value, out Microsoft.Xna.Framework.Vector2 result);
Parameters
value
ReadOnlySpan<Char>
The string value.
result
Vector2
The result if successful, otherwise a default Vector2
Returns
true
if the value
was successfully parsed into result
; false
if the parsing was unsuccessful.