OElite.Restme.Utils 2.1.0-develop.449

OElite.Restme.Utils

NuGet Version Target Framework

Core utility library for the Restme framework, providing essential helper functions, extensions, and foundational types used across the OElite platform.

🚀 Key Features

Core Utilities

  • String Processing: Advanced string manipulation, validation, and formatting utilities
  • Encryption & Security: MD5, DES/3DES encryption helpers with secure key generation
  • Date & Time: Comprehensive date/time utilities and conversions
  • Type Conversion: Robust type conversion and validation helpers
  • GUID Operations: Enhanced GUID generation and manipulation

Web & HTTP Utilities

  • HTTP Content Types: Custom form-encoded and RESTful HTTP content handling
  • Web Crawling: HTML parsing and web scraping utilities with HtmlAgilityPack integration
  • Query Processing: URL query string and parameter handling

Foundation Types

  • BaseEntity: Core entity base class with common properties (Id, CreatedOnUtc, UpdatedOnUtc)
  • Entity Status: Standardized entity status enumeration
  • Query Abstractions: Base query classes for data access patterns
  • Exception Handling: Custom OElite exception types with detailed error information

Installation

dotnet add package OElite.Restme.Utils

Quick Start

String Validation and Processing

using OElite;

// String validation
string validated = StringUtils.CanNotBeNullOrEmpty(userInput);

// String manipulation
string truncated = StringUtils.SubString(longText, 100, "...");
string cleaned = StringUtils.CleanHtmlTags(htmlContent);

// String formatting
string titleCase = StringUtils.ToTitleCase("hello world");

Encryption and Security

using OElite;

// MD5 hashing
string hash = EncryptHelper.Md5Encrypt("password123");

// DES encryption
byte[] key = EncryptHelper.GetDesKey();
string encrypted = EncryptHelper.DesEncrypt("sensitive data", key);
string decrypted = EncryptHelper.DesDecrypt(encrypted, key);

// TOTP generation
string totpCode = TotpEncrypt.GenerateTotp(secretKey);
bool isValid = TotpEncrypt.ValidateTotp(userCode, secretKey);

Type Utilities

using OElite;

// Numeric operations
decimal amount = NumericUtils.ParseDecimal(userInput);
bool isValidNumber = NumericUtils.IsValidCurrency(priceText);

// Boolean processing
bool result = BooleanUtils.ParseBoolean(checkboxValue);

// GUID operations
string shortGuid = GuidUtils.CreateShortGuid();
Guid parsed = GuidUtils.ParseGuid(guidString);

Core Utilities

String Processing

// Validation
string validated = StringUtils.CanNotBeNullOrEmpty(userInput, trim: true);

// Safe substring operations
string excerpt = StringUtils.SubString(content, 150, "...");

// HTML processing
string plainText = StringUtils.StripHtmlTags(htmlContent);
string safeHtml = StringUtils.SanitizeHtml(userInput);

// Text formatting
string titleCase = StringUtils.ToTitleCase("hello world");
string slug = StringUtils.CreateSlug("Product Name Here!");

Date and Time Processing

// Current time operations
DateTime utcNow = DateTimeUtils.GetUtcNow();
DateTime localTime = DateTimeUtils.ConvertToLocal(utcTime, timezone);

// Date validation
bool isValid = DateTimeUtils.IsValidDateRange(startDate, endDate);
bool isFuture = DateTimeUtils.IsFutureDate(checkDate);

// Formatting
string displayDate = DateTimeUtils.FormatForDisplay(dateValue);
string isoString = DateTimeUtils.ToIsoString(dateTime);

Numeric Utilities

// Decimal operations
decimal amount = NumericUtils.ParseDecimal(userInput, defaultValue: 0);
bool isValidCurrency = NumericUtils.IsValidCurrency(priceText);

// Safe conversions
int safeInt = NumericUtils.ToInt32(stringValue);
double safeDouble = NumericUtils.ToDouble(numericString);

// Range validation
bool inRange = NumericUtils.IsInRange(value, min: 0, max: 1000);

GUID Operations

// GUID utilities
string shortGuid = GuidUtils.CreateShortGuid();
Guid newGuid = GuidUtils.CreateGuid();
Guid? parsed = GuidUtils.TryParseGuid(guidString);

// Validation
bool isValid = GuidUtils.IsValidGuid(inputString);

Foundation Types

BaseEntity

Core entity base class providing common functionality:

using OElite.Restme.Utils;

public class Customer : BaseEntity
{
    public string Name { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;

    // Inherited properties:
    // - Id (string) - Primary key
    // - CreatedOnUtc (DateTime) - Creation timestamp
    // - UpdatedOnUtc (DateTime) - Last modification timestamp
}

// Using entity status
customer.Status = EntityStatus.Active;

Entity Collections

using OElite.Restme.Utils;

public class CustomerCollection : IEntityCollection<Customer>
{
    public List<Customer> Items { get; set; } = new();
    public int TotalCount { get; set; }
    public int PageIndex { get; set; }
    public int PageSize { get; set; }
}

Security Features

Encryption and Hashing

// MD5 hashing
string hash = EncryptHelper.Md5Encrypt("password123");
byte[] hashBytes = EncryptHelper.Md5Encrypt(dataBytes);

// DES/3DES encryption
byte[] key = EncryptHelper.GetDesKey();
string encrypted = EncryptHelper.DesEncrypt("sensitive data", key);
string decrypted = EncryptHelper.DesDecrypt(encrypted, key);

// TOTP (Time-based One-Time Password)
string totpCode = TotpEncrypt.GenerateTotp(secretKey);
bool isValid = TotpEncrypt.ValidateTotp(userCode, secretKey, timeWindow: 30);

Boolean Utilities

// Parse various boolean representations
bool result = BooleanUtils.ParseBoolean("true");     // true
bool result = BooleanUtils.ParseBoolean("yes");      // true
bool result = BooleanUtils.ParseBoolean("1");        // true
bool result = BooleanUtils.ParseBoolean("on");       // true

// With default values
bool result = BooleanUtils.ParseBoolean(null, defaultValue: false);

Web & HTTP Utilities

HTTP Content Handling

// Custom form-encoded content
var formContent = new OEliteFormUrlEncodedContent(parameters);

// RESTful HTTP content
var restContent = new OEliteRestfulHttpContent(data);

// HTTP response message extensions
HttpResponseMessage response = await httpClient.GetAsync(url);
string content = await response.ReadAsStringAsync();

Web Crawling

// HTML parsing with HtmlAgilityPack integration
var htmlDoc = WebCrawlerUtils.LoadHtmlDocument(url);
string extractedText = WebCrawlerUtils.ExtractText(htmlContent);
var links = WebCrawlerUtils.ExtractLinks(htmlDoc);

// URL and query processing
var parameters = QueryUtils.ParseQueryString(requestUrl);
string encoded = QueryUtils.BuildQueryString(parameterDict);

File and Stream Utilities

// File operations
byte[] fileBytes = FileUtils.ReadAllBytes(filePath);
string fileContent = FileUtils.ReadAllText(filePath);
bool exists = FileUtils.Exists(filePath);

// Stream processing
byte[] streamData = StreamUtils.ReadAllBytes(inputStream);
string streamText = StreamUtils.ReadAllText(inputStream);

Error Handling

using OElite.Restme.Utils;

try
{
    // Operation that might fail
    ProcessUserData(userData);
}
catch (OEliteException ex)
{
    // Handle OElite-specific exceptions
    RestmeLogger.LogError(ex.Message, ex);
}

Integration

OElite.Restme.Utils serves as the foundation for other Restme packages:

  • OElite.Restme.MongoDb: Uses base entities and utilities
  • OElite.Restme.Redis: Leverages caching and serialization utilities
  • OElite.Restme.S3: Uses file and stream utilities
  • OElite.Common: Extends utilities with domain-specific functionality

Requirements

  • .NET 8.0, 9.0, or 10.0
  • HtmlAgilityPack.NetCore 1.5.0.1+
  • Newtonsoft.Json 13.0.3+
  • Microsoft.Extensions.Logging.Abstractions 9.0.0+

Thread Safety

Most utility methods are thread-safe. Thread utilities are provided for concurrent operations and background processing scenarios.

License

Copyright © OElite Limited. All rights reserved.

Showing the top 20 packages that depend on OElite.Restme.Utils.

Packages Downloads
OElite.Restme
RESTme (Restme) is a set of useful toolkits, including RESTful HTTP client, Azure Blob Storage Client, Redis Client as well as many Convertors & Extensions implemented in .NET Core
164
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper
163
OElite.Restme.Dapper
This is a set of Dapper .Net wrappers and helpers aims to simplify data manipulations in large scale applications without compromise of using ORM
160
OElite.Restme
RESTme (Restme) is a set of useful toolkits, including RESTful HTTP client, Azure Blob Storage Client, Redis Client as well as many Convertors & Extensions implemented in .NET Core
145
OElite.Restme.MongoDb
Package Description
144
OElite.Restme.RateLimiting
Production-grade rate limiting middleware for ASP.NET Core applications with support for distributed scenarios, memory and Redis storage, and flexible configuration.
130
OElite.Common
Package Description
102
OElite.Common.Platform
Package Description
98
OElite.Data
Package Description
98
OElite.Restme.Dapper
This is a set of Dapper .Net wrappers and helpers aims to simplify data manipulations in large scale applications without compromise of using ORM
58
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper
58
OElite.Restme.GoogleUtils
Package Description
55
OElite.Restme
RESTme (Restme) is a set of useful toolkits, including RESTful HTTP client, Azure Blob Storage Client, Redis Client as well as many Convertors & Extensions implemented in .NET Core
42
OElite.Restme
RESTme (Restme) is a set of useful toolkits, including RESTful HTTP client, Azure Blob Storage Client, Redis Client as well as many Convertors & Extensions implemented in .NET Core
41
OElite.Restme.MongoDb
Package Description
40
OElite.Restme.GoogleUtils
Package Description
40
OElite.Restme
RESTme (Restme) is a set of useful toolkits, including RESTful HTTP client, Azure Blob Storage Client, Redis Client as well as many Convertors & Extensions implemented in .NET Core
38
OElite.Restme.MongoDb
Package Description
37
OElite.Restme.MongoDb
Package Description
36
OElite.Restme.RateLimiting
Production-grade rate limiting middleware for ASP.NET Core applications with support for distributed scenarios, memory and Redis storage, and flexible configuration.
36

Version Downloads Last updated
2.1.1-develop.508 13 11/22/2025
2.1.0-develop.449 3 11/11/2025
2.1.0-develop.445 3 11/11/2025
2.0.9-develop.442 37 11/10/2025
2.0.9-develop.434 8 11/06/2025
2.0.9-develop.433 3 11/06/2025
2.0.9-develop.432 3 11/06/2025
2.0.9-develop.430 4 11/04/2025
2.0.9-develop.420 6 10/30/2025
2.0.9-develop.419 5 10/30/2025
2.0.9-develop.418 4 10/30/2025
2.0.9-develop.414 11 10/28/2025
2.0.9-develop.413 3 10/28/2025
2.0.9-develop.398 40 10/26/2025
2.0.9-develop.393 14 10/25/2025
2.0.9-develop.390 13 10/25/2025
2.0.9-develop.388 7 10/25/2025
2.0.9-develop.386 7 10/25/2025
2.0.9-develop.257 144 10/20/2025
2.0.9-develop.256 5 10/20/2025
2.0.9-develop.255 5 10/20/2025
2.0.9-develop.254 5 10/20/2025
2.0.9-develop.253 4 10/20/2025
2.0.9-develop.252 5 10/19/2025
2.0.9-develop.251 6 10/19/2025
2.0.9-develop.250 6 10/19/2025
2.0.9-develop.249 4 10/19/2025
2.0.9-develop.248 5 10/19/2025
2.0.9-develop.247 5 10/19/2025
2.0.9-develop.246 4 10/19/2025
2.0.9-develop.245 5 10/19/2025
2.0.9-develop.243 4 10/19/2025
2.0.9-develop.242 8 10/19/2025
2.0.9-develop.241 5 10/19/2025
2.0.9-develop.233 23 10/17/2025
2.0.9-develop.232 5 10/17/2025
2.0.9-develop.230 5 10/17/2025
2.0.9-develop.229 5 10/17/2025
2.0.9-develop.228 5 10/17/2025
2.0.9-develop.223 15 10/16/2025
2.0.9-develop.221 14 10/16/2025
2.0.9-develop.220 4 10/16/2025
2.0.9-develop.214 18 10/15/2025
2.0.9-develop.213 5 10/15/2025
2.0.9-develop.208 20 10/14/2025
2.0.9-develop.207 6 10/14/2025
2.0.9-develop.204 10 10/13/2025
2.0.9-develop.192 13 10/13/2025
2.0.9-develop.191 4 10/13/2025
2.0.9-develop.190 28 10/12/2025
2.0.9-develop.143 5 10/12/2025
2.0.9-develop.142 4 10/10/2025
2.0.9-develop.135 4 10/09/2025
2.0.9-develop.90 5 10/05/2025
2.0.9-develop.79 13 10/02/2025
2.0.9-develop.74 4 10/01/2025
2.0.9-develop.73 4 10/01/2025
2.0.9-develop.71 4 09/26/2025
2.0.9-develop.70 8 09/22/2025
2.0.9-develop.69 4 09/22/2025
2.0.9-develop.68 4 09/22/2025
2.0.9-develop.67 5 09/22/2025
2.0.9-develop.66 5 09/21/2025
2.0.9-develop.65 5 09/21/2025
2.0.9-develop.64 5 09/21/2025
2.0.9-develop.50 19 09/16/2025
2.0.9-develop.49 4 09/16/2025
2.0.9-develop.48 5 09/15/2025
2.0.8-develop.31 9 09/15/2025
2.0.7-develop.30 4 09/15/2025
2.0.6-develop.29 4 09/15/2025
2.0.6-develop.27 4 09/15/2025
2.0.5-develop.26 4 09/15/2025
2.0.5-develop.25 4 09/15/2025
2.0.5-ci990 163 07/20/2025
2.0.4-ci990 43 07/20/2025
2.0.4-ci342 7 07/20/2025