Skip to content

Class Parsers

Definition

Namespace: StardewUI
Assembly: StardewUI.dll

Utilities for parsing third-party types, generally related to MonoGame/XNA.

public static class Parsers

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.

public static Microsoft.Xna.Framework.Color ParseColor(string value);
Parameters

value   string
A string containing a named or hex color.a

Returns

Color

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.

public static Microsoft.Xna.Framework.Rectangle ParseRectangle(string value);
Parameters

value   string
String representation of a Rectangle, having 4 comma-separated integer values.

Returns

Rectangle

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.

public static Microsoft.Xna.Framework.Vector2 ParseVector2(string value);
Parameters

value   string
The string value.

Returns

Vector2

The parsed Vector2.


ParseVector2(ReadOnlySpan<Char>)

Parses a Vector2 from a comma-separated value pair.

public static Microsoft.Xna.Framework.Vector2 ParseVector2(ReadOnlySpan<System.Char> value);
Parameters

value   ReadOnlySpan<Char>
The string value.

Returns

Vector2

The parsed Vector2.


TryParseColor(string, Color)

Attempts to parse a named or hex color as a Color.

public static bool TryParseColor(string value, out Microsoft.Xna.Framework.Color color);
Parameters

value   string
A string containing a named or hex color.a

color   Color
The result if successful, otherwise a default Color.

Returns

Boolean

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

Boolean

true if the value was successfully parsed into result; false if the parsing was unsuccessful.