Treehopper C# API
Utility Class Reference

This is a utility class that contains convenient static methods. More...

Static Public Member Functions

static void ForEach< T > (this IEnumerable< T > enumeration, Action< T > action)
 Do something with each item in a list, collection, or enumerable More...
 
static string BcdToString (int val, int decimalPlace=0, bool showLeadingZeros=false)
 Convert 4-bit BCD nibbles to a string More...
 
static string ToHexString (this byte[] ba)
 
static void Forget (this Task task)
 Empty method which prevents VS from generating warnings from un-awaited calls. More...
 
static string RandomString (int length)
 Get a random string with alphanumeric characters More...
 
static void Error (string message, bool fatal=false)
 Emit an error message More...
 
static void Error (Exception ex)
 Print an error to the Debug console and throw an exception if the Settings permit More...
 

Detailed Description

This is a utility class that contains convenient static methods.

Member Function Documentation

◆ ForEach< T >()

static void ForEach< T > ( this IEnumerable< T >  enumeration,
Action< T >  action 
)
static

Do something with each item in a list, collection, or enumerable

Template Parameters
TThe type of the enumerable
Parameters
enumerationThe collection, list, etc to operate over
actionThe Action to perform on each item

◆ BcdToString()

static string BcdToString ( int  val,
int  decimalPlace = 0,
bool  showLeadingZeros = false 
)
static

Convert 4-bit BCD nibbles to a string

Parameters
valThe number (composed of 4-bit nibbles) to convert
decimalPlaceWhere to draw a decimal point
showLeadingZerosWhether to show leading zeros
Returns
The string

◆ ToHexString()

static string ToHexString ( this byte []  ba)
static

◆ Forget()

static void Forget ( this Task  task)
static

Empty method which prevents VS from generating warnings from un-awaited calls.

Parameters
task

◆ RandomString()

static string RandomString ( int  length)
static

Get a random string with alphanumeric characters

Parameters
lengthThe number of characters the string should have
Returns
the generated string

◆ Error() [1/2]

static void Error ( string  message,
bool  fatal = false 
)
static

Emit an error message

Parameters
messageThe error to emit
fatalWhether this error is fatal, and should throw an exception

◆ Error() [2/2]

static void Error ( Exception  ex)
static

Print an error to the Debug console and throw an exception if the Settings permit

Parameters
exThe exception message to print

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