c# 3.0 - How to change enum definition without impacting clients using it in C# -


I have been defined following Enum I used to underline because this Enum used in logging and custom attribution Do not use me to enter the upper part of the image. We use very heavy logging now the requirement is to change "LoginFailed_InvalidAttempt1" to "LoginFailed Attempt1" If I change this enum, I have to change its value in my application. I can change the underscores from a place inside the entrance of the SP. Is there any way by which I can change it without affecting the whole application? Please suggest.

  public Enum Akshntaip {there was nothing designed, modified, active, inactive, deleted, login, logout, change password, ResetPassword, InvalidPassword, LoginFailed_LockedAccount, LoginFailed_InActiveAccount, LoginFailed_ExpiredAccount, ForgotPassword, LoginFailed_LockedAccount_InvalidAttempts, LoginFailed_InvalidAttempt1, LoginFailed_InvalidAttempt2, LoginFailed_InvalidAttempt3, ForgotPassword_InvalidAttempt1, ForgotPassword_InvalidAttempt2, ForgotPassword_InvalidAttempt3, SessionTimeOut, ForgotPassword_LockedAccount, LockedAccount, Relogin, ChangePassword_Due_To_Expiration, ChangePassword_AutoExpired}  

The best way to do this is to type Will accompany the feature. I think you do not use reflection, but you can always cache the result, so it happens only once?

DETAILS feature:

  [details while displaying text value ( "LoginFailed Enum, you can get details by using the code the following bit: < / P> 
  private (try1 ")] LoginFailed_InvalidAttempt1  

Fixed dictionary & lt; type, dictionary & lt; enum, string & gt; & gt; EnumMaps = null ; public static string GetDescription (Enum value) {type = EType ValuekGetType (); if (enumMaps == nULL) {enumMaps = new dictionary & lt; type, dictionary & lt; Enum, string & gt; & gt; ( );} Dictionary & lt; Enum, string & gt; Map; if (enumMaps.Contains Key (eType)) {map = enumMaps [eType];} Else {map = new Dictionary & lt; Enum, string & gt; (); Enum.GetValues ​​(eType)) in foreign currency (Enum e {FieldInfo fi = ETypekGetField (EkToString ()); Vivrnviseshta [] attributes = (details entry []) fi.GetCustomAttributes (typeof (DescriptionAttribute), false); map [e] = (attributes. Lang & gt; 0)? Features [0]. Description: E. toaster ();} EnumMaps [eType] = map; } Return map [value]; }

As you can see from the code above, the reflection is only once . At the same NM value, any subsequent call result will be replaced with the dictionary which is fast electricity.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -