Skip to content

Enumerations ​

This page is about the enumerations available in PeyrSharp.Enums. They are grouped by category.

Compatibility ​

Enumerations are part of the PeyrSharp.Enums module, which is compatible with all of these frameworks and platforms:

Package/PlatformWindowsmacOSLinux + others
Enums✅✅✅
Framework.NET 6.NET 7.NET 8
Enums✅✅✅

Converters ​

StorageUnits ​

Definition ​

The StorageUnits enumeration represents all possible numeric storage units. It contains the following values:

ValueNameMeaning
0ByteThe byte unit. (b)
1KilobyteThe kilobyte unit. (kb)
2MegabyteThe megabyte unit. (mb)
3GigabyteThe gigabyte unit. (gb)
4TerabyteThe terabyte unit. (tb)
5PetabyteThe petabyte unit. (pb)

Example ​

c#
public static double ToPetabyte(double value, StorageUnits unit)
{
    if (unit == StorageUnits.Terabyte)
    {
        return value / 1000d;
    }
}

TimeUnits ​

Definition ​

The TimeUnits enumeration represents all possible time units, such as seconds, minutes, etc. A more detailed table on all the values available:

ValueNameMeaning
0MillisecondsRepresents milliseconds.
1SecondsRepresents seconds.
2MinutesRepresents minutes.
3HoursRepresents hours.
4DaysRepresents days.

Example ​

c#
public static double ToSeconds(double value, TimeUnits unit)
{
    if (unit == TimeUnits.Minutes)
    {
        return value * 60;
    }
}

Environment ​

LogLevel ​

Definition ​

The LogLevel enumeration specifies the severity level of a log message. It contains several values:

ValueNameMeaning
0DebugDebug-level messages provide verbose information for debugging purposes.
1InfoInfo-level messages provide informational messages about the application's state.
2WarningWarning-level messages indicate a potential problem or non-critical issue.
3ErrorError-level messages indicate an error has occurred in the application.
4CriticalCritical-level messages indicate a critical error has occurred that requires immediate attention.
5MiscMisc-level messages are for miscellaneous use cases and are not defined in the logging specification.

Example ​

c#
using PeyrSharp.Enums;
using PeyrSharp.Env;

string message = "This is a log message.";
string filePath = @"C:\Logs\log.txt";
DateTime date = DateTime.Now;
LogLevel logLevel = LogLevel.Warning;

Logger.Log(message, filePath, date, logLevel);

More info here about the example

OperatingSystems ​

Definition ​

The OperatingSystems enumerations represents all possible operating systems that a .NET program could run on. It contains several values:

ValueNameMeaning
0WindowsThe Microsoft Windows Operating System.
1macOSThe Apple macOS Operating System.
2LinuxA Linux-based Operating System.
3UnknownAn unknown Operating System.

Example ​

c#
if (Env.CurrentOs == OperatingSystems.Windows)
{
    //Do something if the OS is Windows
}

SystemThemes ​

Definition ​

The SystemThemes enumerations represents all themes available on a Windows device. It contains several values:

ValueNameMeaning
0DarkThe user is using dark theme.
1LightThe user is using light theme.
2UnknownThe current theme is unknown.

Example ​

c#
if (GetCurrentTheme() == SystemThemes.Dark)
{
    Console.WriteLine("You have dark theme enabled!");
}

WindowsVersion ​

Definition ​

The WindowsVersion enumerations represents all possible Windows versions supported by .NET, which means all version from Windows 7 to 11. It contains several values:

ValueNameMeaning
0Windows7The Windows 7 (NT 6.1) Operating System.
1Windows8The Windows 8 (NT 6.2) Operating System.
2Windows81The Windows 8.1 (NT 6.3) Operating System.
3Windows10The Windows 10 (NT 10.0) Operating System.
4Windows11The Windows 11 (NT 10.0, Build 22000+) Operating System.

Example ​

c#
public bool DarkThemeAvailable => Env.CurrentWindowsVersion == WindowsVersion.Windows10 || Env.CurrentWindowsVersion == WindowsVersion.Windows11;

Geometry ​

TriangleSides ​

Definition ​

The TriangleSides enumeration represents the different sides of a triangle: hypotenuse, adjacent, and opposite. It contains these values:

ValueNameMeaning
0OpposedThe opposed side of a specific angle of a triangle.
1HypotenuseThe hypotenuse of a triangle.
2AdjacentThe adjacent side of a specific angle of a triangle.

Example ​

c#
// Get the adjacent side from the opposed side of a specific angle.
Trigonometry.GetAdjacentSideFrom(TriangleSides.Opposed, 20);

Internet ​

StatusCodes ​

Definition ​

The StatusCodes enumeration represents the different kinds of status codes returned by a server after a request is made to it. The following status codes are available in this enumeration:

ValueNameMeaning
0InformationalInformational responses (100-199)
1SuccessSuccessful responses (200-299)
2RedirectionRedirection messages (300-399)
3ClientErrorClient error responses (400-499)
4ServerErrorServer error responses (500-599)

Example ​

c#
status = GetRequestStatus();

switch (status)
{
    case StatusCodes.Informational:
        Console.WriteLine("An information status code has been returned.");
        break;
    case StatusCodes.Success:
        Console.WriteLine("An successful status code has been returned.");
        break;
    case StatusCodes.Redirection:
        Console.WriteLine("An redirection status code has been returned.");
        break;
    case StatusCodes.ClientError:
        Console.WriteLine("An client error status code has been returned.");
        break;
    case StatusCodes.ServerError:
        Console.WriteLine("An server error status code has been returned.");
        break;
}

Password ​

PasswordPresets ​

Definition ​

The PasswordPresets enumeration represents all the of the presets available when generating a password using the Password class of PeyrSharp.Core. It has two values:

ValueNameMeaning
0SimpleThe Simple preset generates a password with simple characters.
1ComplexThe Complex preset generates a password with unusual, hard and complex characters.

Example ​

c#
private async void Main()
{
    string password = Password.GenerateAsync(10, PasswordPresets.Simple); // Generate a simple password
}

PasswordStrength ​

Definition ​

The PasswordStrength enumeration represents different strength levels of a password; if it's a strong or weak password. It contains these values:

ValueNameMeaning
0LowThe password has a low strength; you shouldn't use it.
1MediumThe password has a medium strength; don't use it on important websites.
2GoodThe password has a good strength; you can safely use it.
3VeryGoodThe password has an excellent strength, meaning it will be hard for hackers to hack it.

Example ​

c#
internal async void Main()
{
    // Check if the generated password is complex
    if (Password.GetStrength(await Password.GenerateAsync(15, PasswordPresets.Complex)) == PasswordStrength.Medium)
    {
        Console.WriteLine("The password isn't complex enough.");
    }
}

UserInterface ​

ControlAlignment ​

Definition ​

The ControlAlignment enumeration is here to help align a control when calling methods from the UiHelpers namespace. It has the following values:

ValueNameMeaning
0HorizontalThe control will be aligned/centered horizontally.
1VerticalThe control will be aligned/centered vertically.
2BothThe control will be aligned/centered horizontally and vertically.

Example ​

c#
using PeyrSharp.UiHelpers;

namespace App
{
    public partial class MyForm : Form
    {
        private void button1_Click(object sender, EventArgs e)
        {
            WinFormsHelpers.CenterControl(button1, this, ControlAlignment.Horizontal);
        }
    }
}

Released under the MIT License.