Enigmatry.Entry.SmartEnums
9.1.1-preview.5
dotnet add package Enigmatry.Entry.SmartEnums --version 9.1.1-preview.5
NuGet\Install-Package Enigmatry.Entry.SmartEnums -Version 9.1.1-preview.5
<PackageReference Include="Enigmatry.Entry.SmartEnums" Version="9.1.1-preview.5" />
<PackageVersion Include="Enigmatry.Entry.SmartEnums" Version="9.1.1-preview.5" />
<PackageReference Include="Enigmatry.Entry.SmartEnums" />
paket add Enigmatry.Entry.SmartEnums --version 9.1.1-preview.5
#r "nuget: Enigmatry.Entry.SmartEnums, 9.1.1-preview.5"
#:package Enigmatry.Entry.SmartEnums@9.1.1-preview.5
#addin nuget:?package=Enigmatry.Entry.SmartEnums&version=9.1.1-preview.5&prerelease
#tool nuget:?package=Enigmatry.Entry.SmartEnums&version=9.1.1-preview.5&prerelease
Smart Enums
A library that extends the traditional C# enum concept with rich, type-safe enumeration classes that can contain both data and behavior.
Intended Usage
Use Smart Enums when you need enumerations that contain additional data and behavior beyond simple named constants. Smart Enums provide type-safety, better refactoring support, and the ability to encapsulate logic related to the enumeration.
Installation
Add the package to your project:
dotnet add package Enigmatry.Entry.SmartEnums
Usage Example
Define a Smart Enum:
using Enigmatry.Entry.SmartEnums;
public class PaymentMethod : SmartEnum<PaymentMethod>
{
public static readonly PaymentMethod CreditCard = new(1, nameof(CreditCard), "Credit Card", 0.02m);
public static readonly PaymentMethod DebitCard = new(2, nameof(DebitCard), "Debit Card", 0.01m);
public static readonly PaymentMethod BankTransfer = new(3, nameof(BankTransfer), "Bank Transfer", 0.00m);
public string DisplayName { get; }
public decimal TransactionFee { get; }
private PaymentMethod(int id, string name, string displayName, decimal transactionFee)
: base(id, name)
{
DisplayName = displayName;
TransactionFee = transactionFee;
}
public decimal CalculateFee(decimal amount) => amount * TransactionFee;
}
Using the Smart Enum:
// Get by name
var creditCard = PaymentMethod.FromName("CreditCard");
// Get by ID
var bankTransfer = PaymentMethod.FromId(3);
// Use the properties and methods
decimal fee = creditCard.CalculateFee(100.00m);
// List all values
var allMethods = PaymentMethod.List();
// Equality comparison works correctly
bool isSame = (PaymentMethod.CreditCard == creditCard); // true
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
- Ardalis.SmartEnum (>= 8.2.0)
- Enigmatry.Entry.Core (>= 9.1.1-preview.5)
- JetBrains.Annotations (>= 2024.3.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Enigmatry.Entry.SmartEnums:
Package | Downloads |
---|---|
Enigmatry.Entry.SmartEnums.VerifyTests
Building Block for support of SmartEnums with VerifyTests in an Entry based project |
|
Enigmatry.Entry.SmartEnums.EntityFramework
Building Block for support of SmartEnums with EntityFramework in an Entry based project |
|
Enigmatry.Entry.SmartEnums.SystemTextJson
Building Block for support of SmartEnums with SystemTextJson in an Entry based project |
|
Enigmatry.Entry.SmartEnums.Swagger
Building Block for support of SmartEnums with NSWag in an Entry based project |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
9.1.1-preview.5 | 175 | 8/8/2025 |
9.1.1-preview.4 | 92 | 6/27/2025 |
9.1.1-preview.3 | 128 | 6/4/2025 |
9.1.0 | 170 | 6/3/2025 |
9.0.1-preview.8 | 128 | 5/26/2025 |
9.0.1-preview.7 | 211 | 5/13/2025 |
9.0.1-preview.6 | 298 | 5/9/2025 |
9.0.1-preview.5 | 153 | 5/7/2025 |
9.0.1-preview.4 | 132 | 4/30/2025 |
9.0.1-preview.2 | 133 | 4/1/2025 |
9.0.0 | 195 | 2/26/2025 |
8.1.1-preview.3 | 135 | 5/7/2025 |
8.1.1-preview.1 | 136 | 4/1/2025 |
8.1.0 | 336 | 2/19/2025 |
8.0.1-preview.4 | 79 | 2/7/2025 |
8.0.1-preview.2 | 67 | 1/15/2025 |
8.0.0 | 757 | 11/27/2024 |
3.4.6-preview.10 | 74 | 11/27/2024 |
3.4.3 | 458 | 10/22/2024 |
3.4.2 | 495 | 10/11/2024 |
3.4.1 | 147 | 10/9/2024 |
3.4.0 | 143 | 10/9/2024 |
3.3.2 | 291 | 8/28/2024 |
3.3.2-preview.7 | 99 | 8/27/2024 |