Casper.Library
1.1.9
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Casper.Library --version 1.1.9
NuGet\Install-Package Casper.Library -Version 1.1.9
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="Casper.Library" Version="1.1.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Casper.Library" Version="1.1.9" />
<PackageReference Include="Casper.Library" />
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 Casper.Library --version 1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Casper.Library, 1.1.9"
#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 Casper.Library@1.1.9
#: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=Casper.Library&version=1.1.9
#tool nuget:?package=Casper.Library&version=1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Casper.Library
A utility library for .NET applications providing helpful extensions and attributes for common development tasks.
Features
Enum Extensions
- GetCode() - Retrieve custom codes from enum values using DescriptionAttribute
- GetDescription() - Get descriptions from enum values using DescriptionAttribute
- ToEnum<T>() - Convert strings to enum values with support for:
- Numeric values
- Enum names (case-insensitive)
- Custom codes from DescriptionAttribute
Number Extensions
- ToDecimalDefault() - Convert nullable decimals, doubles, and strings to decimal with default fallback
- ToLongDefault() - Convert nullable longs to long with default fallback
- ToDoubleDefault() - Convert nullable numbers to double with default fallback
- ToIntDefault() - Convert nullable numbers to int with default fallback
Custom Attributes
- DescriptionAttribute - Add custom codes, descriptions, types, and names to enum values
- PermisionAttribute - Define permission-based access control with service, group, and permission hierarchies
Installation
dotnet add package Casper.Library
Usage
Enum Extensions
using Casper.Library.Helpers.Extensions;
using Casper.Library.Helpers.Attributes;
public enum Status
{
[Description(Code = "ACT", Description = "Active")]
Active,
[Description(Code = "INA", Description = "Inactive")]
Inactive
}
// Get custom code
string code = Status.Active.GetCode(); // Returns "ACT"
// Get description
string description = Status.Active.GetDescription(); // Returns "Active"
// Convert string to enum
Status status = "ACT".ToEnum<Status>(); // Returns Status.Active
Number Extensions
using Casper.Library.Helpers.Extensions;
// Convert nullable numbers with default fallback
decimal? nullableDecimal = null;
decimal result = nullableDecimal.ToDecimalDefault(); // Returns 0
// Convert string to decimal with culture support
string numberString = "123.45";
decimal decimalValue = numberString.ToDecimalDefault("en-US"); // Returns 123.45
Permission Attribute
using Casper.Library.Helpers.Attributes;
[Permision(
ServiceCode = "USER",
ServiceName = "User Management",
GroupCode = "ADMIN",
GroupName = "Administration",
PermisionCode = "CREATE",
PermisionName = "Create User",
Description = "Allows creating new users"
)]
public class UserController
{
// Controller implementation
}
Requirements
- .NET 8.0 or later
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
| 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- FluentValidation (>= 12.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- MassTransit (>= 8.5.4)
- MassTransit.RabbitMQ (>= 8.5.4)
- MediatR (>= 11.0.0)
- Microsoft.AspNetCore.Authorization (>= 8.0.20)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Formatters.Json (>= 2.3.0)
- Microsoft.AspNetCore.Routing (>= 2.3.0)
- Microsoft.EntityFrameworkCore (>= 8.0.19)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Http.Polly (>= 8.0.0)
- Microsoft.Extensions.Localization.Abstractions (>= 8.0.19)
- Mono.Cecil (>= 0.11.6)
- Newtonsoft.Json (>= 13.0.3)
- Polly (>= 8.2.0)
- RabbitMQ.Client (>= 7.1.2)
- StackExchange.Redis (>= 2.9.11)
- System.Text.Json (>= 8.0.0)
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.4.3 | 214 | 12/24/2025 |
| 1.4.2 | 497 | 12/9/2025 |
| 1.4.1 | 137 | 11/29/2025 |
| 1.4.0 | 406 | 11/17/2025 |
| 1.3.0 | 248 | 11/14/2025 |
| 1.2.4 | 229 | 11/10/2025 |
| 1.2.3 | 291 | 10/27/2025 |
| 1.2.2 | 265 | 10/24/2025 |
| 1.2.1 | 188 | 10/23/2025 |
| 1.2.0 | 192 | 10/21/2025 |
| 1.1.11 | 285 | 10/20/2025 |
| 1.1.10 | 178 | 10/20/2025 |
| 1.1.9 | 215 | 10/10/2025 |
| 1.1.8 | 170 | 10/10/2025 |
| 1.1.7 | 206 | 10/9/2025 |
| 1.1.6 | 191 | 10/9/2025 |
| 1.1.5 | 197 | 10/3/2025 |
| 1.1.4 | 190 | 10/2/2025 |
| 1.1.3 | 200 | 10/1/2025 |
| 1.1.2 | 176 | 10/1/2025 |
| 1.1.0 | 255 | 9/25/2025 |
| 1.0.11 | 208 | 9/24/2025 |
| 1.0.10 | 165 | 9/24/2025 |
| 1.0.9 | 253 | 9/22/2025 |
| 1.0.8 | 265 | 9/19/2025 |
| 1.0.6 | 273 | 9/19/2025 |
| 1.0.5 | 299 | 9/19/2025 |
| 1.0.4 | 288 | 9/19/2025 |
| 1.0.3 | 293 | 9/19/2025 |
| 1.0.2 | 195 | 9/4/2025 |
| 1.0.1 | 181 | 9/4/2025 |
| 1.0.0 | 166 | 9/4/2025 |