OneCleek.SkyHelpers 1.0.6

dotnet add package OneCleek.SkyHelpers --version 1.0.6
                    
NuGet\Install-Package OneCleek.SkyHelpers -Version 1.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OneCleek.SkyHelpers" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OneCleek.SkyHelpers" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="OneCleek.SkyHelpers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OneCleek.SkyHelpers --version 1.0.6
                    
#r "nuget: OneCleek.SkyHelpers, 1.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OneCleek.SkyHelpers@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OneCleek.SkyHelpers&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=OneCleek.SkyHelpers&version=1.0.6
                    
Install as a Cake Tool

SkyHelpers

A collection of useful C# helpers and extensions for ** .NET 10.0 ** applications.

Platform Requirements

  • Target Framework: .NET 10.0

Helpers

DateHelper

A utility class for friendly date formatting and Hijri date conversion.

Features
  • Relative Time: Converts DateTime to human-readable strings (e.g., "just now", "5 minutes ago", "in 2 days").
  • Hijri Date: Converts Gregorian dates to Hijri dates with support for adjustment and localized month names.
  • Localization: Supports English, French, and Arabic.
Usage
using SkyHelpers;
using System.Globalization;

// Relative Time (Uses current UI culture)
var date = DateTime.Now.AddMinutes(-5);
string relative = DateHelper.RelativeAgo(date); // "5 min ago" (if en)

// Explicit Culture (French)
var frCulture = new CultureInfo("fr");
string relativeFr = DateHelper.RelativeAgo(date, frCulture); // "il y a 5 min"

// Hijri Date
string hijri = DateHelper.GetHijriDate(DateTime.Now); // "10 Ramadan 1445"
string hijriAr = DateHelper.GetHijriDate(DateTime.Now, culture: new CultureInfo("ar")); // "10 رمضان 1445"

LocalizationHelper

Internal helper for retrieving localized strings.

Features
  • GetString: Retrieves a localized string key.
  • GetRelativeString: Helper for past/future relative date strings.
  • Culture Support: Accepts optional CultureInfo, defaults to CurrentUICulture.
Usage (Internal)
string text = LocalizationHelper.GetString("KeyName");
string textFr = LocalizationHelper.GetString("KeyName", new CultureInfo("fr"));

Parse

Safe parsing utilities for common types.

Features
  • Int: Parses to int?. Returns null on failure.
  • Decimal: Parses to decimal. Returns 0 on failure.
  • Double: Parses to double. Returns 0 on failure.
  • Boolean: Parses to bool. Returns false on failure.
  • DateTime: Parses to DateTime?. Returns null on failure.
  • TimeOnly: Parses to TimeOnly?. Returns null on failure.
  • DateOnly: Parses to DateOnly?. Returns null on failure.
Usage
using SkyHelpers;

int? id = Parse.Int("123");
decimal price = Parse.Decimal("19.99");
double lat = Parse.Double("48.8566");
bool isActive = Parse.Boolean("true");
DateTime? date = Parse.DateTime("2023-01-01");
TimeOnly? time = Parse.TimeOnly("14:30");
DateOnly? dateOnly = Parse.DateOnly("2023-12-25");

Hooks

Interfaces for common entity framework entity lifecycle hooks.

Features
  • IBeforeCreate: void BeforeCreate()
  • IBeforeUpdate: void BeforeUpdate()
  • IBeforeDelete: void BeforeDelete()
Usage
using SkyHelpers;

public class MyEntity : IBeforeCreate
{
    public void BeforeCreate()
    {
        // Logic before creation
    }
}

PasswordHelper

BCrypt password hashing compatible with Laravel ($2y$ prefix).

Features
  • HashPassword: Hashes a password with BCrypt (default cost 10) and uses $2y$ prefix.
  • VerifyPassword: Verifies a password against a hash (supports $2y$, $2a$, $2b$).
Usage
using SkyHelpers;

string hash = PasswordHelper.HashPassword("secret");
bool isValid = PasswordHelper.VerifyPassword("secret", hash);

Messages

A unified Twilio wrapper for sending WhatsApp and SMS messages.

Configuration

The Messages class is initialized with your Twilio credentials:

  • accountSid: Your Twilio Account SID.
  • authToken: Your Twilio Auth Token.
  • fromNumber: The Twilio phone number to send from.
  • phoneCode (Optional): Default country dialing code (e.g., "+213"). Defaults to +213.
Methods
  • SendWhatsApp: Sends a WhatsApp message. Returns true on success, false on failure.
  • SendSms: Sends an SMS message. Returns true on success, false on failure.

Both methods automatically handle phone number formats (+, 00, and local numbers with leading 0).

Usage
using SkyHelpers;

var msg = new Messages("AC...", "AuthToken...", "+14155238886");

// Send WhatsApp
bool whatsAppSent = msg.SendWhatsApp("+15551234567", "Hello via WhatsApp!");
if (whatsAppSent)
    Console.WriteLine("WhatsApp sent!");

// Send SMS (requires Messaging Service SID)
bool smsSent = msg.SendSms("0550123456", "Hello via SMS!", "MG...");
if (smsSent)
    Console.WriteLine("SMS sent!");

PhoneCode

A utility class providing a comprehensive list of international dialing codes.

Features
  • GetAll / GetCountryPhoneCodes: Returns a list of CountryInfo objects containing country names and dialing codes (e.g., "Algeria", "+213").
Usage
using SkyHelpers;

var codes = PhoneCode.GetAll();
var dz = codes.FirstOrDefault(c => c.Name == "Algeria");
Console.WriteLine(dz.Code); // Output: +213

MachineIdentifier

Generates a unique hardware-based identifier for the machine running the application.

Features
  • GetUniqueIdentifier: Returns a hashed string derived from CPU ID, BIOS Serial Number, and BaseBoard Serial Number.
  • Fallbacks: Robustly handles missing hardware information by trying multiple identifiers.
Usage
using SkyHelpers;

string uniqueId = MachineIdentifier.GetUniqueIdentifier();
Console.WriteLine(uniqueId); // e.g., "a1b2c3d4..."

ImageHelper

Utilities for manipulating images, converting bytes, and saving files.

Features
  • GetImageBytesFromPath: Safely reads image bytes from a path.
  • GetImageFromPath: Loads an Image object from a path.
  • SaveImageToProjectDirectory: Saves an image to [AppDir]/Images/[SubDirectory].
  • ImageToBytes / BytesToImage: Convenient conversion methods.
  • To24bppRgb: Standardization.
  • ResizeImage: Resizes an image while preserving aspect ratio and optimizing output format (JPEG vs PNG).
Usage
using SkyHelpers;
using System.Drawing;

Image img = ImageHelper.GetImageFromPath("path/to/image.jpg");
byte[] bytes = ImageHelper.ImageToBytes(img);

// Resizing
byte[] originalBytes = File.ReadAllBytes("large_image.jpg");
// Resize to 800px width (height calculated automatically)
byte[] resizedBytes = ImageHelper.ResizeImage(originalBytes, width: 800); 
Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 146 1/13/2026
1.0.5 287 12/15/2025
1.0.4 268 12/15/2025
1.0.3 250 12/15/2025
1.0.2 448 12/11/2025
1.0.1 460 12/9/2025