OElite.Restme.Utils
2.1.1
dotnet add package OElite.Restme.Utils --version 2.1.1
NuGet\Install-Package OElite.Restme.Utils -Version 2.1.1
<PackageReference Include="OElite.Restme.Utils" Version="2.1.1" />
<PackageVersion Include="OElite.Restme.Utils" Version="2.1.1" />
<PackageReference Include="OElite.Restme.Utils" />
paket add OElite.Restme.Utils --version 2.1.1
#r "nuget: OElite.Restme.Utils, 2.1.1"
#:package OElite.Restme.Utils@2.1.1
#addin nuget:?package=OElite.Restme.Utils&version=2.1.1
#tool nuget:?package=OElite.Restme.Utils&version=2.1.1
OElite.Restme.Utils
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.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- HtmlAgilityPack.NetCore (>= 1.5.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Reflection.TypeExtensions (>= 4.7.0)
-
net8.0
- HtmlAgilityPack.NetCore (>= 1.5.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net9.0
- HtmlAgilityPack.NetCore (>= 1.5.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on OElite.Restme.Utils:
| Package | Downloads |
|---|---|
|
OElite.Common
Package Description |
|
|
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 |
|
|
OElite.Restme.Dapper.Common
Restme.Dapper.Common (RESTme) is the common library for Restme.Dapper |
|
|
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 |
|
|
OElite.Restme.BigBuyUtils
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.1 | 468 | 7/21/2026 |
| 2.0.9 | 503 | 11/11/2025 |
| 2.0.6 | 398 | 9/15/2025 |
| 2.0.2-dev4 | 1,015 | 1/9/2020 |
| 2.0.2-dev3 | 923 | 1/9/2020 |
| 2.0.2-dev2 | 958 | 1/9/2020 |
| 2.0.2-dev1 | 1,776 | 1/9/2020 |
| 2.0.2-dev-223 | 1,858 | 9/24/2020 |
| 2.0.1-dev3 | 1,607 | 2/20/2018 |
| 2.0.1-dev2 | 1,143 | 2/20/2018 |
| 2.0.1-dev1 | 1,548 | 2/10/2018 |
| 2.0.0 | 2,444 | 1/21/2018 |
| 2.0.0-dev1 | 1,402 | 2/10/2018 |
| 2.0.0-dev | 1,976 | 11/14/2017 |
| 1.0.3 | 2,081 | 9/15/2016 |
| 1.0.1 | 2,153 | 8/24/2016 |