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
DEFAULT
Constant
public const string DEFAULT = "Default"
Field Value
EnId
Constant
public const string EnId = "D4997C35-6E89-499A-87BF-D5750D0D3F06"
Field Value
FieldAliasSep
Constant
public const string FieldAliasSep = "__"
Field Value
FromField
Constant
public const string FromField = "_FROM"
Field Value
GENERAL
Constant
public const string GENERAL = "General"
Field Value
GrId
Constant
public const string GrId = "92A158E7-25CA-4367-BA57-FB79C40D775C"
Field Value
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
MASTER_KEY_FIELD_NAME
Constant
public const string MASTER_KEY_FIELD_NAME = "MASTER_KEY_FIELD_NAME"
Field Value
NULL
Constant
public const string NULL = "___null___"
Field Value
NamePathSep
Constant
public const string NamePathSep = "."
Field Value
None
Constant
public const string None = "[none]"
Field Value
SYSTEM
Constant
public const string SYSTEM = "System"
Field Value
StandardCompanyGuid
Constant
public const string StandardCompanyGuid = "74772779-BF08-4B22-8F87-196FB87EC7C2"
Field Value
ToField
Constant
public const string ToField = "_TO"
Field Value
Properties
Context
Provides access to the current application execution context.
public static HostContext Context { get; }
Property Value
DebugMode
True when this application is in debug mode.
public static bool DebugMode { get; set; }
Property Value
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
HostName
The name of the local computer
public static string HostName { get; }
Property Value
LogErrorProc
An action that displays error strings to log box.
public static Action<string> LogErrorProc { get; set; }
Property Value
LogExceptionProc
An action that displays exception strings to log box.
public static Action<Exception> LogExceptionProc { get; set; }
Property Value
LogInfoProc
An action that displays info strings to log box.
public static Action<string> LogInfoProc { get; set; }
Property Value
LogWarnProc
An action that displays warning strings to log box.
public static Action<string> LogWarnProc { get; set; }
Property Value
Settings
System global settings
public static SysGlobalSettings Settings { get; }
Property Value
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
UserName
The username of the current user of the local computer
public static string UserName { get; }
Property Value
Methods
AsBoolean(object, bool)
Converts a value to bool, if possible, else returns Default
public static bool AsBoolean(object Value, bool Default = false)
Parameters
Returns
AsDateTime(object, DateTime)
Converts a value to DateTime, if possible, else returns Default
public static DateTime AsDateTime(object Value, DateTime Default)
Parameters
Returns
AsDecimal(object, decimal)
Converts a value to decimal, if possible, else returns Default
public static decimal AsDecimal(object Value, decimal Default = 0)
Parameters
Returns
AsDouble(object, double)
Converts a value to double, if possible, else returns Default
public static double AsDouble(object Value, double Default = 0)
Parameters
Returns
AsInteger(object, int)
Converts a value to int, if possible, else returns Default
public static int AsInteger(object Value, int Default = 0)
Parameters
Returns
AsString(object, string)
Converts a value to string, if possible, else returns Default
public static string AsString(object Value, string Default = "")
Parameters
Returns
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
ValueobjectDefaultT
Returns
- T
Type Parameters
T
DateTimeToStr(DateTime, bool)
Converts a datetime into a string
public static string DateTimeToStr(DateTime Value, bool UseMSecs = false)
Parameters
Returns
DateToStr(DateTime)
Converts a date into a string
public static string DateToStr(DateTime Value)
Parameters
ValueDateTime
Returns
Debug(Exception)
Displays an error message in the debug box.
public static void Debug(Exception e)
Parameters
Debug(string)
Displays a message in the debug box.
public static void Debug(string Text)
Parameters
Textstring
DecimalToStr(decimal, int)
Formats and returns a double value
public static string DecimalToStr(decimal Value, int Digits = 4)
Parameters
Returns
DoubleToStr(double, int)
Formats and returns a double value
public static string DoubleToStr(double Value, int Digits = 4)
Parameters
Returns
EscapeText(string)
Escapes a text so it can be safely used inside a C# string literal.
public static string EscapeText(string Text)
Parameters
Textstring
Returns
GenId()
Creates and returns a new Guid WITHOUT surrounding brackets, i.e. {}
public static string GenId()
Returns
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
UseBracketsbool
Returns
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
Returns
GetApplicationAssemblies(string[])
Returns a list of non-system assemblies
public static List<Assembly> GetApplicationAssemblies(string[] ExcludeAssempliesContaining = null)
Parameters
ExcludeAssempliesContainingstring[]
Returns
GetCurrentAppUserId()
The id of the current application user. Used when an application supports users.
public static string GetCurrentAppUserId()
Returns
GetCurrentAppUserName()
The name of the current application user. Used when an application supports users.
public static string GetCurrentAppUserName()
Returns
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
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
Valueobject
Returns
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
Returns
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
FileNamestring
Returns
LogError(Exception)
Displays an error message in the UI log box.
public static void LogError(Exception e)
Parameters
LogErrorText(string)
Displays an error message in the UI log box.
public static void LogErrorText(string Text)
Parameters
Textstring
LogInfo(string)
Displays an info message in the UI log box.
public static void LogInfo(string Text)
Parameters
Textstring
LogWarn(string)
Displays a warning message in the UI log box.
public static void LogWarn(string Text)
Parameters
Textstring
OpenFileExplorer(string)
Displays the file explorer on a path
public static void OpenFileExplorer(string path)
Parameters
pathstring
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
FilePathstring
Returns
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
Returns
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
Sstring
Returns
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
Returns
StrToValidFileName(string)
Replaces any invalid file name characters from Source with spaces.
public static string StrToValidFileName(string Source)
Parameters
Sourcestring
Returns
Throw(string)
Throws an Exception
public static void Throw(string Text)
Parameters
Textstring
Throw(string, params object[])
Throws an Exception
public static void Throw(string Text, params object[] Args)
Parameters
TryStrToDateTime(string, out DateTime)
Converts a string into a DateTime. Returns true on success.
public static bool TryStrToDateTime(string S, out DateTime Value)
Parameters
Returns
UiLog(string)
Displays a message in the UI log box.
public static void UiLog(string Text)
Parameters
Textstring