DeuceGear.EnumExtensions
1.0.2
dotnet add package DeuceGear.EnumExtensions --version 1.0.2
NuGet\Install-Package DeuceGear.EnumExtensions -Version 1.0.2
<PackageReference Include="DeuceGear.EnumExtensions" Version="1.0.2" />
paket add DeuceGear.EnumExtensions --version 1.0.2
#r "nuget: DeuceGear.EnumExtensions, 1.0.2"
// Install DeuceGear.EnumExtensions as a Cake Addin
#addin nuget:?package=DeuceGear.EnumExtensions&version=1.0.2
// Install DeuceGear.EnumExtensions as a Cake Tool
#tool nuget:?package=DeuceGear.EnumExtensions&version=1.0.2
DeuceGear.EnumExtensions
Extension pack targeting Enums
EnumTextValueAttribute
Define a enum and add EnumTextValue attributes to the values:
public enum LeEnum
{
EmptyValue,
[EnumTextValue("The value of SingleValue")]
SingleValue,
[EnumTextValue("The first value of ListValue")]
[EnumTextValue("The second value of ListValue")]
ListValue
}
Get the first available value using the TextValue method. If no value is found, the method reverts to ToString():
var emptyResult = LeEnum.EmptyValue.TextValue()
// emptyResult will be "EmptyValue"
var singleResult = LeEnum.SingleValue.TextValue()
// singleResult will be "The value of SingleValue"
var listResult = LeEnum.ListValue.TextValue()
// listResult will be "The first value of ListValue"
Get all values if any via the TextValues method:
var emptyResult = LeEnum.EmptyValue.TextValues()
// emptyResult will be an IEnumerable<string> without items
var singleResult = LeEnum.SingleValue.TextValues()
// singleResult will be an IEnumerable<string> with one item: "The value of SingleValue"
var listResult = LeEnum.ListValue.TextValues()
// listResult will be an IEnumerable<string> with 2 items: ["The first value of ListValue", "The second value of ListValue"]
Breaking changes
v1.0.0 > v1.0.1
- EnumValueAttribute got renamed to EnumTextValueAttribute
Enums
DeuceGear.Enums contains commonly used methods for Enums.
EnumList
DeuceGear.Enums.EnumList<T>() gives you a list of possible enum values for the given type <T>. The first call to this method caches the data to make future calls for this type much faster. In other words, if you only need the list once, stick with "typeof(T).GetEnumValues()".
var result = Enums.EnumList<LeEnum>()
// result while be an IEnumerable of Enums.
This method has also a little brother, namely DeuceGear.Enums.EnumIntList<T,Ttarget>(). This returns a simple array of Ttarget with all possible values. The Enum needs to implement the Ttarget type ofcourse.
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 | net452 is compatible. net46 was computed. net461 is compatible. 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. |
-
.NETFramework 4.5.2
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 2.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.