Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
/ EnumAnnotation Public archive

Enum wrapper for more conviently accessing the Data Annotations Attributes

License

Notifications You must be signed in to change notification settings

aadje/EnumAnnotation

Repository files navigation

EnumAnnotation DisplayAttribute

Build status NuGet version (EnumAnnotation)

Enum wrapper for more conviently accessing the Display DataAnnotation Attribute on an Enum

  1. Use by copy-pasting EnumAnnotation.cs into your project, and modify as you see fit
  2. Or reference the assembly using Nuget Install-Package EnumAnnotation
  • Use the in .net 4 added System.ComponentModel.DataAnnotations.DisplayAnnotation to add friendly names to your Enum
  • Generate Lists with enum names and values to bind in your UI, using EnumAnnotation.GetDisplays<SomeStatus>();
    Filter these Lists by supplying the enum values explicitly
    EnumAnnotation.GetDisplays(SomeStatus.Fine, SomeStatus.Ok);
    or using a lambda predicate function
    EnumAnnotation.GetDisplays<SomeStatus>(a => a.Name != "Fine");
  • Add multiple names to your Enums using the DisplayAnnotations Name, ShortName, Desciption and GroupName properties
  • Supports the DisplayAnnotation.ResourceType to add localization to the Name, ShortName, Desciption and GroupName properties using standard resx files. See example and unit tests
  • Extension method to easy access a DisplayAttribute on a single enum value, which looks like SomeStatus.Fine.GetDisplay();,
  • or access the Name value directly, using SomeStatus.Fine.GetName();
  • Reorder your Enum using the DisplayAnnotion.Order property, without changing the Enums Underying value
  • Portable libary that supports .Net 4.03, Silverlight 5 and Windows 8 and up. Portable libraries are supported in Nuget 2.1 and up

About

Enum wrapper for more conviently accessing the Data Annotations Attributes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages