OElite.Restme.Utils 2.1.1-develop.994

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 © Phanes Technology Ltd. All rights reserved.

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

Packages Downloads
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper
728
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
728
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
727
OElite.Restme.GoogleUtils
Package Description
504
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper
7
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
7
OElite.Restme.MongoDb
Package Description
5
OElite.Common.AspNetCore
Package Description
5
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
5
OElite.Common
Package Description
5
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.
5
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
5
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
4
OElite.Data.Repositories
Package Description
4
OElite.Restme.GoogleUtils
Package Description
4
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper
4
OElite.Common
Package Description
4
OElite.Data
Package Description
4
OElite.Common.Platform
Package Description
3

Version Downloads Last updated
2.1.1-develop.994 0 06/16/2026
2.1.1-develop.952 2 06/05/2026
2.1.1-develop.951 1 06/05/2026
2.1.1-develop.949 2 06/04/2026
2.1.1-develop.931 2 06/01/2026
2.1.1-develop.568 3 03/08/2026
2.1.1-develop.521 5 03/08/2026
2.1.1-develop.520 2 03/08/2026
2.1.1-develop.519 2 03/08/2026
2.1.1-develop.518 2 03/08/2026
2.1.1-develop.516 2 03/08/2026
2.1.1-develop.513 2 03/08/2026
2.1.1-develop.508 2 03/08/2026
2.1.0-develop.449 2 03/08/2026
2.1.0-develop.445 2 03/08/2026
2.0.9-develop.442 2 03/08/2026
2.0.9-develop.434 2 03/08/2026
2.0.9-develop.433 2 03/08/2026
2.0.9-develop.432 2 03/08/2026
2.0.9-develop.430 2 03/08/2026
2.0.9-develop.420 2 03/08/2026
2.0.9-develop.419 2 03/08/2026
2.0.9-develop.418 2 03/08/2026
2.0.9-develop.414 2 03/08/2026
2.0.9-develop.413 2 03/08/2026
2.0.9-develop.398 2 03/08/2026
2.0.9-develop.393 2 03/08/2026
2.0.9-develop.390 3 03/08/2026
2.0.9-develop.388 2 03/08/2026
2.0.9-develop.386 2 03/08/2026
2.0.9-develop.257 2 03/08/2026
2.0.9-develop.256 2 03/08/2026
2.0.9-develop.255 2 03/08/2026
2.0.9-develop.254 2 03/08/2026
2.0.9-develop.253 2 03/08/2026
2.0.9-develop.252 2 03/08/2026
2.0.9-develop.251 2 03/08/2026
2.0.9-develop.250 2 03/08/2026
2.0.9-develop.249 2 03/08/2026
2.0.9-develop.248 2 03/08/2026
2.0.9-develop.247 2 03/08/2026
2.0.9-develop.246 2 03/08/2026
2.0.9-develop.245 2 03/08/2026
2.0.9-develop.243 2 03/08/2026
2.0.9-develop.242 2 03/08/2026
2.0.9-develop.241 2 03/08/2026
2.0.9-develop.233 2 03/08/2026
2.0.9-develop.232 2 03/08/2026
2.0.9-develop.230 2 03/08/2026
2.0.9-develop.229 2 03/08/2026
2.0.9-develop.228 2 03/08/2026
2.0.9-develop.223 2 03/08/2026
2.0.9-develop.221 2 03/08/2026
2.0.9-develop.220 2 03/08/2026
2.0.9-develop.214 2 03/08/2026
2.0.9-develop.213 2 03/08/2026
2.0.9-develop.208 2 03/08/2026
2.0.9-develop.207 2 03/08/2026
2.0.9-develop.204 2 03/08/2026
2.0.9-develop.192 2 03/08/2026
2.0.9-develop.191 2 03/08/2026
2.0.9-develop.190 2 03/08/2026
2.0.9-develop.143 2 03/08/2026
2.0.9-develop.142 2 03/08/2026
2.0.9-develop.135 2 03/08/2026
2.0.9-develop.90 2 03/08/2026
2.0.9-develop.79 2 03/08/2026
2.0.9-develop.74 2 03/08/2026
2.0.9-develop.73 2 03/08/2026
2.0.9-develop.71 2 03/08/2026
2.0.9-develop.70 2 03/08/2026
2.0.9-develop.69 2 03/08/2026
2.0.9-develop.68 2 03/08/2026
2.0.9-develop.67 2 03/08/2026
2.0.9-develop.66 2 03/08/2026
2.0.9-develop.65 2 03/08/2026
2.0.9-develop.64 2 03/08/2026
2.0.9-develop.50 2 03/08/2026
2.0.9-develop.49 2 03/08/2026
2.0.9-develop.48 2 03/08/2026
2.0.8-develop.31 2 03/08/2026
2.0.7-develop.30 2 03/08/2026
2.0.6-develop.29 2 03/08/2026
2.0.6-develop.27 2 03/08/2026
2.0.5-develop.26 2 03/08/2026
2.0.5-develop.25 2 03/08/2026
2.0.5-ci990 727 03/08/2026
2.0.4-ci990 4 03/08/2026
2.0.4-ci342 2 03/08/2026