Table of Contents

Class Sys

Namespace
Tripous
Assembly
Tripous.dll

System-related utilities.

public static class Sys
Inheritance
Sys
Inherited Members

Fields

APPLICATION

Constant

public const string APPLICATION = "Application"

Field Value

string

DEFAULT

Constant

public const string DEFAULT = "Default"

Field Value

string

EnId

Constant

public const string EnId = "D4997C35-6E89-499A-87BF-D5750D0D3F06"

Field Value

string

FieldAliasSep

Constant

public const string FieldAliasSep = "__"

Field Value

string

FromField

Constant

public const string FromField = "_FROM"

Field Value

string

GENERAL

Constant

public const string GENERAL = "General"

Field Value

string

GrId

Constant

public const string GrId = "92A158E7-25CA-4367-BA57-FB79C40D775C"

Field Value

string

ISODateTimeFormats

An array of ISO8601 datetime formats

public static readonly string[] ISODateTimeFormats

Field Value

string[]

InvalidId

Constant

public const string InvalidId = "27C15428-7892-4F7D-B28F-9BA059C94BA4"

Field Value

string

MASTER_KEY_FIELD_NAME

Constant

public const string MASTER_KEY_FIELD_NAME = "MASTER_KEY_FIELD_NAME"

Field Value

string

NULL

Constant

public const string NULL = "___null___"

Field Value

string

NamePathSep

Constant

public const string NamePathSep = "."

Field Value

string

None

Constant

public const string None = "[none]"

Field Value

string

SYSTEM

Constant

public const string SYSTEM = "System"

Field Value

string

StandardCompanyGuid

Constant

public const string StandardCompanyGuid = "74772779-BF08-4B22-8F87-196FB87EC7C2"

Field Value

string

ToField

Constant

public const string ToField = "_TO"

Field Value

string

Properties

Context

Provides access to the current application execution context.

public static HostContext Context { get; }

Property Value

HostContext

DebugMode

True when this application is in debug mode.

public static bool DebugMode { get; set; }

Property Value

bool

DebugProc

An action that displays debug strings to lob box. It is passed by the Ui static class.

public static Action<string> DebugProc { get; set; }

Property Value

Action<string>

HostName

The name of the local computer

public static string HostName { get; }

Property Value

string

LogErrorProc

An action that displays error strings to log box.

public static Action<string> LogErrorProc { get; set; }

Property Value

Action<string>

LogExceptionProc

An action that displays exception strings to log box.

public static Action<Exception> LogExceptionProc { get; set; }

Property Value

Action<Exception>

LogInfoProc

An action that displays info strings to log box.

public static Action<string> LogInfoProc { get; set; }

Property Value

Action<string>

LogWarnProc

An action that displays warning strings to log box.

public static Action<string> LogWarnProc { get; set; }

Property Value

Action<string>

Settings

System global settings

public static SysGlobalSettings Settings { get; }

Property Value

SysGlobalSettings

UiLogProc

An action that displays UI log strings to lob box. It is passed by the Ui static class.

public static Action<string> UiLogProc { get; set; }

Property Value

Action<string>

UserName

The username of the current user of the local computer

public static string UserName { get; }

Property Value

string

Methods

AsBoolean(object, bool)

Converts a value to bool, if possible, else returns Default

public static bool AsBoolean(object Value, bool Default = false)

Parameters

Value object
Default bool

Returns

bool

AsDateTime(object, DateTime)

Converts a value to DateTime, if possible, else returns Default

public static DateTime AsDateTime(object Value, DateTime Default)

Parameters

Value object
Default DateTime

Returns

DateTime

AsDecimal(object, decimal)

Converts a value to decimal, if possible, else returns Default

public static decimal AsDecimal(object Value, decimal Default = 0)

Parameters

Value object
Default decimal

Returns

decimal

AsDouble(object, double)

Converts a value to double, if possible, else returns Default

public static double AsDouble(object Value, double Default = 0)

Parameters

Value object
Default double

Returns

double

AsInteger(object, int)

Converts a value to int, if possible, else returns Default

public static int AsInteger(object Value, int Default = 0)

Parameters

Value object
Default int

Returns

int

AsString(object, string)

Converts a value to string, if possible, else returns Default

public static string AsString(object Value, string Default = "")

Parameters

Value object
Default string

Returns

string

AsValue<T>(object, T)

Returns the Value as a value of T. If is null returns Default.

public static T AsValue<T>(object Value, T Default)

Parameters

Value object
Default T

Returns

T

Type Parameters

T

DateTimeToStr(DateTime, bool)

Converts a datetime into a string

public static string DateTimeToStr(DateTime Value, bool UseMSecs = false)

Parameters

Value DateTime
UseMSecs bool

Returns

string

DateToStr(DateTime)

Converts a date into a string

public static string DateToStr(DateTime Value)

Parameters

Value DateTime

Returns

string

Debug(Exception)

Displays an error message in the debug box.

public static void Debug(Exception e)

Parameters

e Exception

Debug(string)

Displays a message in the debug box.

public static void Debug(string Text)

Parameters

Text string

DecimalToStr(decimal, int)

Formats and returns a double value

public static string DecimalToStr(decimal Value, int Digits = 4)

Parameters

Value decimal
Digits int

Returns

string

DoubleToStr(double, int)

Formats and returns a double value

public static string DoubleToStr(double Value, int Digits = 4)

Parameters

Value double
Digits int

Returns

string

EscapeText(string)

Escapes a text so it can be safely used inside a C# string literal.

public static string EscapeText(string Text)

Parameters

Text string

Returns

string

GenId()

Creates and returns a new Guid WITHOUT surrounding brackets, i.e. {}

public static string GenId()

Returns

string

GenId(bool)

Creates and returns a new Guid.

If UseBrackets is true, the new guid is surrounded by {}

public static string GenId(bool UseBrackets)

Parameters

UseBrackets bool

Returns

string

GenerateRandomString(int, string)

Creates and returns a random string of a specified length, picking characters from a specified set of characters.

public static string GenerateRandomString(int Length, string CharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

Parameters

Length int
CharSet string

Returns

string

GetApplicationAssemblies(string[])

Returns a list of non-system assemblies

public static List<Assembly> GetApplicationAssemblies(string[] ExcludeAssempliesContaining = null)

Parameters

ExcludeAssempliesContaining string[]

Returns

List<Assembly>

GetCurrentAppUserId()

The id of the current application user. Used when an application supports users.

public static string GetCurrentAppUserId()

Returns

string

GetCurrentAppUserName()

The name of the current application user. Used when an application supports users.

public static string GetCurrentAppUserName()

Returns

string

GetFiles(string, string, bool)

Returns file names from the specified Folder that match the specified Filters.

Filters is a list of filters delimited by semicolon, i.e. *.gif;*.jpg;*.png;*.bmp;

The returned file names include the full path.

public static string[] GetFiles(string Folder, string Filters, bool SearchSubFolders = false)

Parameters

Folder string
Filters string
SearchSubFolders bool

Returns

string[]

GetInvalidFileNameChars()

Returns an array containing the characters that are not allowed in file names.

public static char[] GetInvalidFileNameChars()

Returns

char[]

IsNull(object)

Returns true if Value is null or DBNull

public static bool IsNull(object Value)

Parameters

Value object

Returns

bool

IsSameText(string, string)

Case insensitive string equality.

Returns true if 1. both are null, 2. both are empty string or 3. they are the same string

public static bool IsSameText(string A, string B)

Parameters

A string
B string

Returns

bool

IsValidFileName(string)

Returns true if FileName is a valid file name, that is it just contains characters that are allowed in file names.

public static bool IsValidFileName(string FileName)

Parameters

FileName string

Returns

bool

LogError(Exception)

Displays an error message in the UI log box.

public static void LogError(Exception e)

Parameters

e Exception

LogErrorText(string)

Displays an error message in the UI log box.

public static void LogErrorText(string Text)

Parameters

Text string

LogInfo(string)

Displays an info message in the UI log box.

public static void LogInfo(string Text)

Parameters

Text string

LogWarn(string)

Displays a warning message in the UI log box.

public static void LogWarn(string Text)

Parameters

Text string

OpenFileExplorer(string)

Displays the file explorer on a path

public static void OpenFileExplorer(string path)

Parameters

path string

RegisterAllEncodings()

Unlocks all Code Pages (Greek, DOS, etc.) for the entire application.

public static void RegisterAllEncodings()

RemoveTrailingSlash(string)

Removes a trailing slash mark (e.g. c:\Temp\ ) from a file path.

public static string RemoveTrailingSlash(string FilePath)

Parameters

FilePath string

Returns

string

StrToDate(string, DateTime)

Converts a string to a DateTime.Date value. The string must be defined in one of the ISODateTimeFormats

public static DateTime StrToDate(string S, DateTime Default)

Parameters

S string
Default DateTime

Returns

DateTime

StrToDateTime(string)

Converts a string to a DateTime value. The string must be defined in one of the ISODateTimeFormats

public static DateTime StrToDateTime(string S)

Parameters

S string

Returns

DateTime

StrToDateTime(string, DateTime)

Converts a string to a DateTime value. The string must be defined in one of the ISODateTimeFormats

public static DateTime StrToDateTime(string S, DateTime Default)

Parameters

S string
Default DateTime

Returns

DateTime

StrToValidFileName(string)

Replaces any invalid file name characters from Source with spaces.

public static string StrToValidFileName(string Source)

Parameters

Source string

Returns

string

Throw(string)

Throws an Exception

public static void Throw(string Text)

Parameters

Text string

Throw(string, params object[])

Throws an Exception

public static void Throw(string Text, params object[] Args)

Parameters

Text string
Args object[]

TryStrToDateTime(string, out DateTime)

Converts a string into a DateTime. Returns true on success.

public static bool TryStrToDateTime(string S, out DateTime Value)

Parameters

S string
Value DateTime

Returns

bool

UiLog(string)

Displays a message in the UI log box.

public static void UiLog(string Text)

Parameters

Text string