tag:blogger.com,1999:blog-9202309254227413537.post2427189711683180052..comments2024-03-05T02:12:07.935-08:00Comments on Peretz.Net: .NET Enum The Next LevelMikehttp://www.blogger.com/profile/01090154270652506561noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-9202309254227413537.post-12991652794604978212009-01-16T04:21:00.000-08:002009-01-16T04:21:00.000-08:00Hi,nice idea. If you want to hide the attribute ac...Hi,<BR/>nice idea. If you want to hide the attribute access, you can use Extension Methods:<BR/><BR/> public static class ManagerTypeExtensions {<BR/> public static ManagerAttribute Attribute(this ManagerType value) {<BR/> return EnumDescriptionAttribute.GetAttribute<ManagerAttribute>(value);<BR/> }<BR/><BR/> public static string Description(this ManagerType value) {<BR/> return value.Attribute().Description;<BR/> }<BR/><BR/> public static int MinSalary(this ManagerType value) {<BR/> return value.Attribute().MinSalary;<BR/> }<BR/><BR/> public static int MaxSalary(this ManagerType value) {<BR/> return value.Attribute().MaxSalary;<BR/> }<BR/> }<BR/><BR/> [TestFixture]<BR/> public class ManagerTypeTest {<BR/> [Test]<BR/> public void StoreManagerTest(){<BR/> var sm = ManagerType.StoreManager;<BR/><BR/> Assert.AreEqual("Store Manager", sm.Description());<BR/> Assert.AreEqual(40000, sm.MinSalary());<BR/> Assert.AreEqual(100000, sm.MaxSalary());<BR/> }<BR/><BR/> }Anonymousnoreply@blogger.com