Core utilities and extensions for Orion IRC Server
$ dotnet add package Orion.Foundations
Core utilities and extensions for the Orion IRC Server project.
IRC is not dead, long live IRC!
Orion.Foundations provides essential utilities, extensions, and base classes for building IRC server components. This library forms the foundation of the Orion IRC Server ecosystem, offering common functionality that can be used across various Orion modules or in your own IRC-related projects.
dotnet add package Orion.Foundations
Or using the Package Manager Console:
Install-Package Orion.Foundations
{ENV_VAR}using Orion.Foundations.Extensions;
// Convert string to Base64
string encoded = "Hello, World!".ToBase64();
// Convert Base64 to string
string decoded = encoded.FromBase64();
// Check if a string is Base64
bool isBase64 = encoded.IsBase64String();
using Orion.Foundations.Extensions;
// Get Unix timestamp
long timestamp = DateTime.UtcNow.ToUnixTimestamp();
// Convert from Unix timestamp
DateTime date = timestamp.FromEpoch();
using Orion.Foundations.Extensions;
string text = "HelloWorld";
string snake = text.ToSnakeCase(); // "hello_world"
string camel = text.ToCamelCase(); // "helloWorld"
string pascal = text.ToPascalCase(); // "HelloWorld"
string kebab = text.ToKebabCase(); // "hello-world"
string title = text.ToTitleCase(); // "Hello World"
string upper = text.ToSnakeCaseUpper(); // "HELLO_WORLD"
using Orion.Foundations.Extensions;
string template = "The home directory is {HOME}";
string result = template.ReplaceEnvVariable();
using Orion.Foundations.Utils;
// Create password hash
string hashedPassword = HashUtils.CreatePassword("myPassword");
// Verify password
bool isValid = HashUtils.VerifyPassword("myPassword", hashedPassword);
// Generate secure key
string key = HashUtils.GenerateBase64Key();
// AES encryption
byte[] encrypted = HashUtils.Encrypt("sensitive data", key.FromBase64ToByteArray());
string decrypted = HashUtils.Decrypt(encrypted, key.FromBase64ToByteArray());
using Orion.Foundations.Extensions;
string portRange = "6660-6669,6697";
IEnumerable<int> ports = portRange.ToPorts();
// Returns: 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6667, 6668, 6669, 6697
using Orion.Foundations.Extensions;
// Convert special patterns
var anyAddress = "*".ToIpAddress(); // Returns IPAddress.Any (0.0.0.0)
var ipv6Any = "::".ToIpAddress(); // Returns IPAddress.IPv6Any (::)
// Normal conversion
var loopback = "127.0.0.1".ToIpAddress();
using Orion.Foundations.Utils;
var result = await DnsUtils.TryResolveHostnameAsync("192.168.1.1");
if (result.Resolved)
{
Console.WriteLine($"Hostname: {result.HostName}");
}
using Orion.Foundations.Extensions;
// Serialize to YAML
var config = new MyConfig();
string yaml = config.ToYaml();
// Deserialize from YAML
var loadedConfig = yaml.FromYaml<MyConfig>();
using Orion.Foundations.Pool;
// Create a pool of reusable objects
var pool = new ObjectPool<MyDisposableClass>();
// Get an object from the pool
var obj = pool.Get();
// Use the object...
// Return it to the pool when done
pool.Return(obj);
This project is licensed under the MIT License - see the LICENSE file for details.