Skip to content

A converter between an enum and a related text which is defined by an attribute.

License

Notifications You must be signed in to change notification settings

ikngtty/EnumConversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnumConversion

A converter between an enum and a related text which is defined by an attribute.

Environment

  • This program needs .NET framework 4.0 or later.
  • This program is tested with NUnit 2.6.4.
  • This program is created with Sharp Develop 5.1.

Example of use

private enum Department
{
  [EnumValue("")]
  None,

  [EnumValue("DEV")]
  Development,

  [EnumValue("MNG")]
  Management,
}

public static void Main(string[] args)
{
  string developmentCode = EnumConverter<Department>.ToValue(Department.Development);
  string managementCode = EnumConverter<Department>.ToValue(Department.Management);
  // → "DEV"
  // → "MNG"

  Department development = EnumConverter<Department>.ToEnum("DEV");
  Department management = EnumConverter<Department>.ToEnum("MNG");
  // → Department.Development
  // → Department.Management
}

License

MIT License (see LICENSE.txt)

Used Library

NUnit 2.6.4 (src/lib/NUnit-2_6_4)

  • Author
    Portions Copyright © 2002-2014 Charlie Poole
    or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
    or Copyright © 2000-2002 Philip A. Craig

  • License
    NUnit License (see license/NUnit-2_6_4.txt)

About

A converter between an enum and a related text which is defined by an attribute.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages