VOOZH about

URL: https://www.nuget.org/packages/Enums.Net/

⇱ NuGet Gallery | Enums.NET 5.0.0




Enums.NET 5.0.0

dotnet add package Enums.NET --version 5.0.0
 
 
NuGet\Install-Package Enums.NET -Version 5.0.0
 
 
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="Enums.NET" Version="5.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enums.NET" Version="5.0.0" />
 
Directory.Packages.props
<PackageReference Include="Enums.NET" />
 
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 Enums.NET --version 5.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Enums.NET, 5.0.0"
 
 
#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 Enums.NET@5.0.0
 
 
#: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=Enums.NET&version=5.0.0
 
Install as a Cake Addin
#tool nuget:?package=Enums.NET&version=5.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Enums.NET is a high-performance type-safe .NET enum utility library which provides many operations as convenient extension methods. It is compatible with .NET Framework 4.6.1+ and .NET Standard 2.0+.

Enums.NET Demo

using System;
using System.Linq;
using EnumsNET;
using Xunit;
using DescriptionAttribute = System.ComponentModel.DescriptionAttribute;

public class EnumsNETDemo
{
 // Enum definitions at bottom

 [Fact]
 public void Enumerate()
 {
 var count = 0;
 // Retrieves all enum members in increasing value order
 foreach (var member in Enums.GetMembers<NumericOperator>())
 {
 NumericOperator value = member.Value;
 string name = member.Name;
 AttributeCollection attributes = member.Attributes;
 ++count;
 }
 Assert.Equal(8, count);

 count = 0;
 // Retrieves distinct values in increasing value order
 foreach (var value in Enums.GetValues<NumericOperator>(EnumMemberSelection.Distinct))
 {
 string name = value.GetName();
 AttributeCollection attributes = value.GetAttributes();
 ++count;
 }
 Assert.Equal(6, count);
 }

 [Fact]
 public void FlagEnumOperations()
 {
 // HasAllFlags
 Assert.True((DaysOfWeek.Monday | DaysOfWeek.Wednesday | DaysOfWeek.Friday).HasAllFlags(DaysOfWeek.Monday | DaysOfWeek.Wednesday));
 Assert.False(DaysOfWeek.Monday.HasAllFlags(DaysOfWeek.Monday | DaysOfWeek.Wednesday));

 // HasAnyFlags
 Assert.True(DaysOfWeek.Monday.HasAnyFlags(DaysOfWeek.Monday | DaysOfWeek.Wednesday));
 Assert.False((DaysOfWeek.Monday | DaysOfWeek.Wednesday).HasAnyFlags(DaysOfWeek.Friday));

 // CombineFlags ~ bitwise OR
 Assert.Equal(DaysOfWeek.Monday | DaysOfWeek.Wednesday, DaysOfWeek.Monday.CombineFlags(DaysOfWeek.Wednesday));
 Assert.Equal(DaysOfWeek.Monday | DaysOfWeek.Wednesday | DaysOfWeek.Friday, FlagEnums.CombineFlags(DaysOfWeek.Monday, DaysOfWeek.Wednesday, DaysOfWeek.Friday));

 // CommonFlags ~ bitwise AND
 Assert.Equal(DaysOfWeek.Monday, DaysOfWeek.Monday.CommonFlags(DaysOfWeek.Monday | DaysOfWeek.Wednesday));
 Assert.Equal(DaysOfWeek.None, DaysOfWeek.Monday.CommonFlags(DaysOfWeek.Wednesday));

 // RemoveFlags
 Assert.Equal(DaysOfWeek.Wednesday, (DaysOfWeek.Monday | DaysOfWeek.Wednesday).RemoveFlags(DaysOfWeek.Monday));
 Assert.Equal(DaysOfWeek.None, (DaysOfWeek.Monday | DaysOfWeek.Wednesday).RemoveFlags(DaysOfWeek.Monday | DaysOfWeek.Wednesday));

 // GetFlags, splits out the individual flags in increasing significance bit order
 var flags = DaysOfWeek.Weekend.GetFlags().ToList();
 Assert.Equal(2, flags.Count);
 Assert.Equal(DaysOfWeek.Sunday, flags[0]);
 Assert.Equal(DaysOfWeek.Saturday, flags[1]);
 }

 [Fact]
 public void AsString()
 {
 // AsString, equivalent to ToString
 Assert.Equal("Equals", NumericOperator.Equals.AsString());
 Assert.Equal("-1", ((NumericOperator)(-1)).AsString());

 // GetName
 Assert.Equal("Equals", NumericOperator.Equals.GetName());
 Assert.Null(((NumericOperator)(-1)).GetName());

 // Get description
 Assert.Equal("Is", NumericOperator.Equals.AsString(EnumFormat.Description));
 Assert.Null(NumericOperator.LessThan.AsString(EnumFormat.Description));

 // Get description if applied, otherwise the name
 Assert.Equal("LessThan", NumericOperator.LessThan.AsString(EnumFormat.Description, EnumFormat.Name));
 }

 [Fact]
 public void Validate()
 {
 // Standard Enums, checks is defined
 Assert.True(NumericOperator.LessThan.IsValid());
 Assert.False(((NumericOperator)20).IsValid());

 // Flag Enums, checks is valid flag combination or is defined
 Assert.True((DaysOfWeek.Sunday | DaysOfWeek.Wednesday).IsValid());
 Assert.False((DaysOfWeek.Sunday | DaysOfWeek.Wednesday | ((DaysOfWeek)(-1))).IsValid());

 // Custom validation through IEnumValidatorAttribute<TEnum>
 Assert.True(DayType.Weekday.IsValid());
 Assert.True((DayType.Weekday | DayType.Holiday).IsValid());
 Assert.False((DayType.Weekday | DayType.Weekend).IsValid());
 }

 [Fact]
 public void CustomEnumFormat()
 {
 EnumFormat symbolFormat = Enums.RegisterCustomEnumFormat(member => member.Attributes.Get<SymbolAttribute>()?.Symbol);
 Assert.Equal(">", NumericOperator.GreaterThan.AsString(symbolFormat));
 Assert.Equal(NumericOperator.LessThan, Enums.Parse<NumericOperator>("<", ignoreCase: false, symbolFormat));
 }

 [Fact]
 public void Attributes()
 {
 Assert.Equal("!=", NumericOperator.NotEquals.GetAttributes().Get<SymbolAttribute>().Symbol);
 Assert.True(Enums.GetMember<NumericOperator>("GreaterThanOrEquals").Attributes.Has<PrimaryEnumMemberAttribute>());
 Assert.False(NumericOperator.LessThan.GetAttributes().Has<DescriptionAttribute>());
 }

 [Fact]
 public void Parsing()
 {
 Assert.Equal(NumericOperator.GreaterThan, Enums.Parse<NumericOperator>("GreaterThan"));
 Assert.Equal(NumericOperator.NotEquals, Enums.Parse<NumericOperator>("1"));
 Assert.Equal(NumericOperator.Equals, Enums.Parse<NumericOperator>("Is", ignoreCase: false, EnumFormat.Description));

 Assert.Equal(DaysOfWeek.Monday | DaysOfWeek.Wednesday, Enums.Parse<DaysOfWeek>("Monday, Wednesday"));
 Assert.Equal(DaysOfWeek.Tuesday | DaysOfWeek.Thursday, FlagEnums.ParseFlags<DaysOfWeek>("Tuesday | Thursday", ignoreCase: false, delimiter: "|"));
 }

 enum NumericOperator
 {
 [Symbol("="), Description("Is")]
 Equals,
 [Symbol("!="), Description("Is not")]
 NotEquals,
 [Symbol("<")]
 LessThan,
 [Symbol(">="), PrimaryEnumMember] // PrimaryEnumMember indicates enum member as primary duplicate for extension methods
 GreaterThanOrEquals,
 NotLessThan = GreaterThanOrEquals,
 [Symbol(">")]
 GreaterThan,
 [Symbol("<="), PrimaryEnumMember]
 LessThanOrEquals,
 NotGreaterThan = LessThanOrEquals
 }

 [AttributeUsage(AttributeTargets.Field)]
 class SymbolAttribute : Attribute
 {
 public string Symbol { get; }

 public SymbolAttribute(string symbol)
 {
 Symbol = symbol;
 }
 }

 [Flags]
 enum DaysOfWeek
 {
 None = 0,
 Sunday = 1,
 Monday = 2,
 Tuesday = 4,
 Wednesday = 8,
 Thursday = 16,
 Friday = 32,
 Weekdays = Monday | Tuesday | Wednesday | Thursday | Friday,
 Saturday = 64,
 Weekend = Sunday | Saturday,
 All = Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday
 }

 [Flags, DayTypeValidator]
 enum DayType
 {
 Weekday = 1,
 Weekend = 2,
 Holiday = 4
 }

 class DayTypeValidatorAttribute : EnumValidatorAttribute<DayType>
 {
 public override bool IsValid(DayType value) => value.GetFlagCount(DayType.Weekday | DayType.Weekend) == 1 && FlagEnums.IsValidFlagCombination(value);
 }
}
Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 is compatible.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net461 net461 is compatible.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (109)

Showing the top 5 NuGet packages that depend on Enums.NET:

Package Downloads
NPOI

.NET port of Apache POI

Xpand.XAF.Modules.Reactive

The `Reactive` module provides a XAF DSL API for functional/stateless implementations.

Xpand.Extensions.XAF

Xpand.Extensions.XAF

Vonage

Official C#/.NET wrapper for the Vonage API. To use it you will need a Vonage account. Sign up for free at vonage.com. For full API documentation refer to developer.vonage.com.

Xpand.Extensions.Reactive

Xpand.Extensions.Reactive

GitHub repositories (17)

Showing the top 17 popular GitHub repositories that depend on Enums.NET:

Repository Stars
nissl-lab/npoi
a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
opserver/Opserver
Stack Exchange's Monitoring System
ardalis/SmartEnum
A base class for quickly and easily creating strongly typed enum replacements in C#.
PoESkillTree/PoESkillTree
A Passive Skill Tree Planner for Path of Exile
xin9le/FastEnum
The world fastest enum utilities for C#/.NET
EtienneLamoureux/TQVaultAE
Extra bank space for Titan Quest Anniversary Edition
Windows-Apps-Hub/UnitedSets
Bring back Sets and tabs by grouping windows into tabs
jexuswebserver/JexusManager
Jexus Manager http://jexusmanager.com
SnowflakePowered/snowflake
:snowflake: :video_game: Emulator Frontend and SDK
eXpandFramework/eXpand
DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
antikmozib/Dupe-Clear
A duplicate file cleaner for Windows and Linux.
EncompassRest/EncompassRest
Encompass API .NET Client Library
topnguyen/Elect
The collection of utilities, best practice and fluent method for .NET Core
Vonage/vonage-dotnet-sdk
Vonage REST API client for .NET, written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
AkiniKites/AloysAdjustments
Mods for Horizon Zero Dawn
horse-framework/horse-messaging
Open Source Messaging Framework. Queues, Channels, Events, Transactions, Distributed Cache
chen-junji/YouYouFramework
Version Downloads Last Updated
5.0.0 12,701,293 5/3/2024
4.0.2 1,584,328 1/17/2024
4.0.1 28,243,525 11/18/2022
4.0.0 13,065,198 1/29/2021
3.0.3 3,413,893 1/23/2020
3.0.2 216,197 12/6/2019
3.0.1 309,533 11/11/2019
3.0.0 136,078 11/2/2019
2.3.2 6,674,303 6/23/2018
2.3.1 195,326 12/15/2017
2.3.0 63,883 11/21/2017
2.2.0 82,980 6/6/2017
2.1.1 31,576 3/25/2017
2.0.0 135,524 1/1/2017
1.0.0 14,443 11/5/2016
Loading failed