EpicEnums 1.2023.7.291832
See the version list below for details.
dotnet add package EpicEnums --version 1.2023.7.291832
NuGet\Install-Package EpicEnums -Version 1.2023.7.291832
<PackageReference Include="EpicEnums" Version="1.2023.7.291832" />
paket add EpicEnums --version 1.2023.7.291832
#r "nuget: EpicEnums, 1.2023.7.291832"
// Install EpicEnums as a Cake Addin #addin nuget:?package=EpicEnums&version=1.2023.7.291832 // Install EpicEnums as a Cake Tool #tool nuget:?package=EpicEnums&version=1.2023.7.291832
Epic Enums
Think the standard C# enums are boring? Yeah, same! Lets improve that.
What does it solve/improve on?
Common c# enums are a powerfull tool for constant data. They are fast and simple. However they sometimes lack the flexibility that you want in a complex application.
Here is a standard C# enum like we all know:
public enum FruitsEnum
{
Apple,
Banana,
Orange,
DragonFruit
}
All pretty standard nothing special, however if we want to tie some extra properties to our fruit then things get a little tricky. We could of course add an attribute and make it work:
public enum FruitsEnum
{
[Display(Name = "Apple")]
Apple,
[Display(Name = "Banana")]
Banana,
[Display(Name = "Orange")]
Orange,
[Display(Name = "Dragon Fruit")]
DragonFruit
}
First of all, this is not very readable and can get messy quickly. Most importantly: To access these values you have to write code using reflection to access these properties: (as per stackoverflow)
public static class Extensions
{
/// <summary>
/// A generic extension method that aids in reflecting
/// and retrieving any attribute that is applied to an `Enum`.
/// </summary>
public static TAttribute GetAttribute<TAttribute>(this Enum enumValue)
where TAttribute : Attribute
{
return enumValue.GetType()
.GetMember(enumValue.ToString())
.First()
.GetCustomAttribute<TAttribute>();
}
}
public class Foo
{
public FruitsEnum Fruit = FruitsEnum.Apple;
public void DisplayName()
{
var fruitDisplayName = Fruit.GetAttribute<DisplayAttribute>();
Console.WriteLine("Which friot is it?");
Console.WriteLine (fruitDisplayName.Name);
}
}
Reflection can be slow and give issues in AOT compiling. Plus it can be kind of tedious.
A Better enum
(The name epic enums was chosen because it alliterats ever so lovely)
Installing the package
The epic enums package can be found on nuget.
dotnet add package EpicEnums
Creating an Epic Enum
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.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.2023.10.231942 | 312 | 10/23/2023 |
1.2023.10.231827 | 137 | 10/23/2023 |
1.2023.10.182059 | 123 | 10/18/2023 |
1.2023.8.31931 | 159 | 8/3/2023 |
1.2023.7.310908 | 158 | 7/31/2023 |
1.2023.7.301221 | 205 | 7/30/2023 |
1.2023.7.301215 | 158 | 7/30/2023 |
1.2023.7.301213 | 152 | 7/30/2023 |
1.2023.7.301040 | 148 | 7/30/2023 |
1.2023.7.291844 | 166 | 7/29/2023 |
1.2023.7.291842 | 153 | 7/29/2023 |
1.2023.7.291832 | 138 | 7/29/2023 |
1.2023.7.291628 | 158 | 7/29/2023 |
1.2023.7.291624 | 154 | 7/29/2023 |
1.2023.7.291615 | 166 | 7/29/2023 |
1.2023.7.291611 | 178 | 7/29/2023 |
1.2023.7.291608 | 180 | 7/29/2023 |
1.2023.7.291606 | 165 | 7/29/2023 |
1.2023.7.291553 | 144 | 7/29/2023 |
1.2023.7.291551 | 251 | 7/29/2023 |
1.0.0 | 160 | 7/29/2023 |