Casper.Library 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Casper.Library --version 1.0.2
                    
NuGet\Install-Package Casper.Library -Version 1.0.2
                    
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.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Casper.Library" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Casper.Library" />
                    
Project file
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.0.2
                    
#r "nuget: Casper.Library, 1.0.2"
                    
#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.0.2
                    
#: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.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Casper.Library&version=1.0.2
                    
Install as a Cake Tool

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 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

    • No dependencies.

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