Class StringFunctions

This static class provides string handling functions.

System.Object
  Stonefield.Library.StringFunctions
public static class StringFunctions : object

Class Members

MemberDescription

AddBS

Adds a trailing backslash to the specified path if one isn’t already there.

public static string AddBS(string path)

AddSuffixToFileName

Adds a suffix to the specified filename, before the extension.

public static string AddSuffixToFileName(string path,     string suffix)

Between

Find the content of a string between two delimiters.

public static string Between(string src,     string findfrom,     string findto)

CleanName

Converts non-alpha or digit characters to underscores.

public static string CleanName(string name)

DecryptString

Decrypt the given string. Assumes the string was encrypted using EncryptStringAES(), using an identical sharedSecret.

public static string DecryptString(string cipherText,     string sharedSecret)

EncryptString

Encrypt the given string using AES. The string can be decrypted using DecryptStringAES(). The sharedSecret parameters must match.

public static string EncryptString(string plainText,     string sharedSecret)

FindWidestValueInField

Finds the widest value in the specified column based on the specified font and size.

public static TextSize FindWidestValueInField(DataTable table,     string fieldName,     Font font,     GraphicsUnit units,     string format)

public static TextSize FindWidestValueInField(DataTable table,     string fieldName,     Font font,     GraphicsUnit units,     Func<Object,String> formatter)

GetFieldName

Returns the field name from an aliased fieldname.

public static string GetFieldName(string fieldname)

GetTableName

Returns the table name from an aliased fieldname.

public static string GetTableName(string fieldname)

MakeAbsolutePath

Create an absolute path from a path and a relative path.

public static string MakeAbsolutePath(string path,     string relativePath)

MakeRelativePath

Creates a relative path from one file or folder to another.

public static string MakeRelativePath(string fromPath,     string pathRelativeTo)

MaxValue<T,TCompare>

public static T MaxValue<T,TCompare>(IEnumerable collection,     Func<T,TCompare> func)

NthIndexOf

Extension method to find the index of the Nth occurrence of a character in a string.

public static int NthIndexOf(string s,     char c,     int n)

Replace

Extension method for String that allows a case-insensitive Replace.

public static string Replace(string originalString,     string oldValue,     string newValue,     StringComparison comparison)

ReplaceFilenameInPath

Replaces the filename in a path with another file name, preserving the path

public static string ReplaceFilenameInPath(string path,     string newFilename)

ReplaceWord

Performs a replace on whole words, rather than substrings. This is similar to WordStrTran in SQ.VFP, except this version doesn't account for having non-word characters as the first or last character in oldvalue. So, for example, if you want to replace "tablename" in "tablename.fieldname", call this with "tablename" as the oldvalue, rather than "tablename."

public static string ReplaceWord(string replacein,     string oldvalue,     string newvalue)

UrlDecode

Extension method to URL decode a string.

public static string UrlDecode(string s)

UrlEncode

Extension method to URL encode a string.

public static string UrlEncode(string s)

ValidFileName

Converts illegal characters in the specified filename to underscores.

public static string ValidFileName(string name)

Requirements

Namespace: Stonefield.Library
Assembly: library.dll