RansauSysteme.Utils
1.3.0
dotnet add package RansauSysteme.Utils --version 1.3.0
NuGet\Install-Package RansauSysteme.Utils -Version 1.3.0
<PackageReference Include="RansauSysteme.Utils" Version="1.3.0" />
<PackageVersion Include="RansauSysteme.Utils" Version="1.3.0" />
<PackageReference Include="RansauSysteme.Utils" />
paket add RansauSysteme.Utils --version 1.3.0
#r "nuget: RansauSysteme.Utils, 1.3.0"
#:package RansauSysteme.Utils@1.3.0
#addin nuget:?package=RansauSysteme.Utils&version=1.3.0
#tool nuget:?package=RansauSysteme.Utils&version=1.3.0
RansauSysteme.Utils
A comprehensive collection of utility methods for .NET Core/.NET 8 applications, providing robust solutions for common development tasks.
Installation
Install the package from NuGet:
dotnet add package RansauSysteme.Utils
Or using the Package Manager Console:
Install-Package RansauSysteme.Utils
Features
String Utilities
The StringUtils class provides various string manipulation methods:
// Convert strings to different cases
string snakeCase = "MyVariable".ToSnakeCase(); // "my_variable"
string capitalized = "hello world".Capitalize(); // "Hello World"
string camelCase = "user_first_name".ToCamelCase(); // "userFirstName"
// Other string operations
string truncated = "This is a long text".Truncate(10); // "This is a..."
I/O Utilities
The IOUtils class makes file and directory operations more robust:
// Create files and directories safely
IOUtils.CreateFile("path/to/new/file.txt");
// Copy directories recursively
IOUtils.CopyDirectory("source", "destination");
// Create timestamped filenames
string filename = IOUtils.DatetimeFilename(DateTime.Now); // "2025-02-26_15-30-00"
JSON Utilities
The JsonUtils class simplifies working with JSON:
// Serialize objects to JSON
string json = JsonUtils.ToJson(myObject);
// Deserialize JSON to objects
MyClass? obj = JsonUtils.ParseJson<MyClass>(jsonString);
// Load JSON from files
Configuration? config = JsonUtils.ParseFile<Configuration>("config.json");
// Save objects as JSON files
JsonUtils.SaveToFile(myObject, "data.json");
Database Utilities
The DatabaseUtils class helps with database-related operations:
// Generate secure random passwords
string password = DatabaseUtils.GeneratePassword(length: 12);
// Validate passwords against security requirements
bool isValid = DatabaseUtils.IsValidPassword(
password,
minPasswordLength: 8,
requireUppercase: true,
requireLowercase: true,
requireDigit: true,
requireSpecialChar: true
);
// Or use predefined security levels
bool isValid = DatabaseUtils.IsValidPassword(
password,
strength: PasswordStrength.VeryStrong
);
Result Pattern
The Result<T> class provides a clean way to handle operation results:
// Create success results
Result<User> userResult = Result<User>.Success(user);
// Create failure results
Result<User> failedResult = Result<User>.Failure("User not found");
// Use in methods
public Result<User> GetUser(int id)
{
var user = _repository.FindById(id);
if (user == null)
return Result<User>.Failure("User not found");
return Result<User>.Success(user);
}
// Check results
if (result.IsSuccess)
{
// Use result.Data
}
else
{
// Handle error using result.Error
}
Build Utils
The BuildUtils class provides information about the current build:
// Check if running in debug mode
if (BuildUtils.IsDebug)
{
// Do additional logging
}
// Get environment information
string summary = BuildUtils.GetSummary();
// "Build Configuration: Debug
// Version: 1.0.0.0
// OS: Windows
// Process: 64-bit
// Build Date: 2025-02-26 15:30:00"
Requirements
- .NET 8.0 or higher
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RansauSysteme.Utils:
| Package | Downloads |
|---|---|
|
RansauSysteme.Database
A flexible .NET data access library implementing the Repository pattern for database operations. Features include: - Generic repository implementation with full CRUD operations - Support for MySQL databases with extensible design for other providers - Both synchronous and asynchronous API - Efficient batch operations with transaction support - Built-in caching repository with configurable refresh intervals - Factory pattern for creating repositories with dependency injection support - Comprehensive error handling with custom exceptions - Thread-safe implementation for concurrent applications Designed for developers who want a clean, maintainable approach to database access in .NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.