Advanced Software Engineering
Advanced_Software_Engineering.Verbs.Value.ValueHelper Class Reference

This class contains a large amount of useful conversions More...

Static Public Member Functions

static int ConvertToInt (string text)
 Converts string to int (if possible) More...
 
static double ConvertToDouble (string text)
 Converts string to double (if possible) More...
 
static Point ConvertToPoint (string text1, string text2)
 Converts two strings to a point object. More...
 
static Color TextToColor (string text)
 This function convers text to Color. More...
 
static Color IntsToColor (int r, int g, int b, int a=255)
 Generate a color from RGB(A) int values More...
 
static bool ConvertToBool (string text)
 Convert to boolean More...
 
static IValue ConvertToIValue (string text, ValueStorage storage=null)
 Converts the text to IValue More...
 

Detailed Description

This class contains a large amount of useful conversions

Member Function Documentation

◆ ConvertToBool()

static bool Advanced_Software_Engineering.Verbs.Value.ValueHelper.ConvertToBool ( string  text)
static

Convert to boolean

Parameters
textA text boolean
Returns
boolean representation of the text

◆ ConvertToDouble()

static double Advanced_Software_Engineering.Verbs.Value.ValueHelper.ConvertToDouble ( string  text)
static

Converts string to double (if possible)

Parameters
textString to be converted to double
Returns
Double representation of string

◆ ConvertToInt()

static int Advanced_Software_Engineering.Verbs.Value.ValueHelper.ConvertToInt ( string  text)
static

Converts string to int (if possible)

Parameters
textString to be converted to int
Returns
Integer representation of string

◆ ConvertToIValue()

static IValue Advanced_Software_Engineering.Verbs.Value.ValueHelper.ConvertToIValue ( string  text,
ValueStorage  storage = null 
)
static

Converts the text to IValue

Parameters
texttext to convert
storagestorage to use (can be null) (optional)
Returns
An IValue representation of the text

◆ ConvertToPoint()

static Point Advanced_Software_Engineering.Verbs.Value.ValueHelper.ConvertToPoint ( string  text1,
string  text2 
)
static

Converts two strings to a point object.

Parameters
text1X parameter
text2Y parameter
Returns
A Point object

<todo>Make unit tests for this function</todo>

◆ IntsToColor()

static Color Advanced_Software_Engineering.Verbs.Value.ValueHelper.IntsToColor ( int  r,
int  g,
int  b,
int  a = 255 
)
static

Generate a color from RGB(A) int values

Parameters
rRed
gGreen
bBlue
aOptional: Alpha/Transparancy (default is 255, 0 is transparent)
Returns

◆ TextToColor()

static Color Advanced_Software_Engineering.Verbs.Value.ValueHelper.TextToColor ( string  text)
static

This function convers text to Color.

It can parse several different types of strings. Types of string accepted:

  • A string that is the name of a predefined color. See Color class for full list.
  • A string that represents a Hex Triplet (
    #rrggbb
    ). See .
  • A string that represents a Hex Quadruplet (
    #rrggbbaa
    , where
    aa
    represents alpha).

Color tmp = TextToColor("red"); Console.WriteLine("Name: " + tmp.toString()) //=> "red"

tmp = TextToColor("deadbe"); Console.WriteLine("Name: " + tmp.toString()) //=> "00deadbe"

//It's important to remember that C# doesn't work like HTML colors, putting alpha first, rather than last.

tmp = TextToColor("deadbeef"); Console.WriteLine("Name: " + tmp.toString()) //=> "efdeadbe"

Parameters
texta string with a valid name or format
Returns
color of the string

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