-
Notifications
You must be signed in to change notification settings - Fork 0
Helpers
Alex van den Berg edited this page Feb 13, 2024
·
5 revisions
The string helpers class contains helper function especially made for string manipulation
Function | Description |
---|---|
StripAfterString | Remove all chars in a string after a specified string |
IsInvalidDate | Returns boolean telling if the specified date string is a valid date |
Pad | Pad a specified string with numbers or chars |
SplitString | Split a string using a specified delimiter on a specified posistion |
StringBetween | Get the string between two specified chars |
Mid | Get the string between the start and end posistion |
JoinString | Create a string from a array using the specified delimiter |
StartsWith | Tells if a string begins with a specified string, returns boolean |
EnsWith | Tells if a string end with the specified string, returns boolean |
Contains | Tells if a string contains the specified string, returns boolean |
IsNullOrWhiteSpace | Returns a boolean, telling if the specified string is a whitespace or null |
Escape | Mysql or json escape a specified string |
TruncateEllipsis | Truncates a specfied string at the specified posistion if longer than the specified length |
Helpers can be used for various purposes
Function | Description |
---|---|
MapPath | The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server |
GeneratePincode | Generates a 4 digit pincode |
PushArrayIntoArray | Pushes the given array into another array |
FirstOrDefault | Gets the first item from a specified array |
RepairJson | Repairs a json string by removing invisible chars |
GetMimeType | Gets the mimetype of a specified file |
Now | Gets the now date and returns the date as a string |
GetPageContent | Gets the content of a specified url. It will download the content and return it as a string |
CreateFolderIfNotExists | Creates a folder if it not already exists |
GetFileContent | Get the contents of a file on the server, uses the MapPath method |
DownloadExternalFile | Downloads a external file to the server, based on the specified url |
RandomInteger | Creates a random integer between the specified lower and uperbound values |
NewGuid | Generates a guid |
Use the converter helpers to convert values
Function | Description |
---|---|
ArrayToObject | Convert a array to a specified object / model |
ToMoney | Converts a specified value to a money value with eurosign - example: € XX,XX |
ToSizeFormatFromBytes | Converts to a string containing MB, GB, KB, etc. - example: XX GB |
ToPercentage | Converts two integer values to a percentage |
SecondsToTimeserial | Converts seconds to a timeserial like XX:XX:XX |
Various helper function for the current remote device
Function | Description |
---|---|
UserAgent | Gets the current user agent |
DeviceType | Gets the current device type (computer, mobile, etc.) |
IP | Gets the current IP address |
Hostname | Gets the current hostname |
OS | Gets the current operatingsystem |
Browser | Gets the current used browser (Firefox, Chrome, IE, etc.) |
DeviceGuid | Gets the device guid based on the loggedin userId, IP and OS |