public static object Parse(Type tType, string sValue, bool bIgnoreCase) { object oReturnObj = null; string sEnumStringValue = string.Empty; if (!(ConventionSupport.IsTypeEnum(tType))) { string sArgExceptionMsg = String.Format("Parameter 'Type' must be an Enum. 'Type' used : {0}", tType.ToString()); throw new ArgumentException(ConventionSupport.ProduceErrorMsg(sArgExceptionMsg)); } foreach (FieldInfo fInfo in tType.GetFields()) { StringValueAttribute[] svaAttribs = fInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[]; if (svaAttribs.Length > 0) { sEnumStringValue = svaAttribs [0].ValueOf; } if (string.Compare(sEnumStringValue, sValue, bIgnoreCase) == 0) { oReturnObj = Enum.Parse(tType, fInfo.Name); break; } } return(oReturnObj); }
public static string ProduceErrorMsg(string sMsg) { return(ConventionSupport.ErrorMsgPrefix + ConventionSupport.GetCurrentMethodName( ) + sMsg + ConventionSupport.NewLine); }
public static bool IsFalse(bool bConditon) { if ((!(bConditon != false))) { Debug.WriteLine("AssertFailed"); ConventionSupport.GetCurrentMethodName( ); } return(bConditon); }
public static bool AreEqual(bool bConditon) { if (bConditon != true) { Debug.WriteLine("AssertFailed"); ConventionSupport.GetCurrentMethodName( ); } return(bConditon); }
public StringEnum(Type tEnumType) { if (!ConventionSupport.IsTypeEnum(tEnumType)) { string sArgExceptionMsg = String.Format("Parameter 'Type' must be an Enum. 'Type' used : {0}", tEnumType.ToString()); throw new ArgumentException(ConventionSupport.ProduceErrorMsg(sArgExceptionMsg)); } mT_enumType = tEnumType; }
private static void ErrorDump() { ConventionSupport.GetCurrentMethodName( ); }