CustomEnumBuilder 1.0.0

This class library allows users to create a value type enum class

Install-Package CustomEnumBuilder -Version 1.0.0
dotnet add package CustomEnumBuilder --version 1.0.0
<PackageReference Include="CustomEnumBuilder" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CustomEnumBuilder --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CustomEnumBuilder, 1.0.0"
For F# scripts that support #r syntax, copy this into the source code to reference the package.
// Install CustomEnumBuilder as a Cake Addin
#addin nuget:?package=CustomEnumBuilder&version=1.0.0

// Install CustomEnumBuilder as a Cake Tool
#tool nuget:?package=CustomEnumBuilder&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

This class library allows users to create custom enum classes. This allows users to assign a value other than an integer.

Use Case example:

  1. Create a class that Inherits from the Enumeration<> class
public class Gender : Enumeration<string>{

}
  1. Implement the abstract methods
public class Gender : Enumeration<string>{ 

       public Gender(string value, string displayName):base(value, displayName){} 

}
  1. Add your custom enum types
public class Gender : Enumeration<string>{
     public Gender(string value, string displayName):base(value, displayName){}

      public static Gender Male = new Gender("M", "Male");
      public static Gender Female = new Gender("F", "Female");
      public static Gender Unknown = new Gender("U", "Unknown");
}

After this you can use the enumeration classes to compare values based on the type instead of just integers.

Example:

if(Gender.Male == "M"){ 
     return "the value of Gender.Male is M" 
    }

Another Example using an int as a backing value:

public class LicenseType : Enumeration<int>
{
        public LicenseType(int value, string displayName) : base(value, displayName) {   }
       
        public static LicenseType Drivers = new LicenseType(1,"Drivers Or State IDs");
        public static LicenseType Professional = new LicenseType(2,"Professional");        
 }

This class library allows users to create custom enum classes. This allows users to assign a value other than an integer.

Use Case example:

  1. Create a class that Inherits from the Enumeration<> class
public class Gender : Enumeration<string>{

}
  1. Implement the abstract methods
public class Gender : Enumeration<string>{ 

       public Gender(string value, string displayName):base(value, displayName){} 

}
  1. Add your custom enum types
public class Gender : Enumeration<string>{
     public Gender(string value, string displayName):base(value, displayName){}

      public static Gender Male = new Gender("M", "Male");
      public static Gender Female = new Gender("F", "Female");
      public static Gender Unknown = new Gender("U", "Unknown");
}

After this you can use the enumeration classes to compare values based on the type instead of just integers.

Example:

if(Gender.Male == "M"){ 
     return "the value of Gender.Male is M" 
    }

Another Example using an int as a backing value:

public class LicenseType : Enumeration<int>
{
        public LicenseType(int value, string displayName) : base(value, displayName) {   }
       
        public static LicenseType Drivers = new LicenseType(1,"Drivers Or State IDs");
        public static LicenseType Professional = new LicenseType(2,"Professional");        
 }

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

Version History

Version Downloads Last updated
1.0.0 284 1/22/2020