예제 #1
0
        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);
        }
예제 #2
0
 public static string ProduceErrorMsg(string sMsg)
 {
     return(ConventionSupport.ErrorMsgPrefix +
            ConventionSupport.GetCurrentMethodName( ) +
            sMsg +
            ConventionSupport.NewLine);
 }
예제 #3
0
 public static bool IsFalse(bool bConditon)
 {
     if ((!(bConditon != false)))
     {
         Debug.WriteLine("AssertFailed");
         ConventionSupport.GetCurrentMethodName( );
     }
     return(bConditon);
 }
예제 #4
0
            public static bool AreEqual(bool bConditon)
            {
                if (bConditon != true)
                {
                    Debug.WriteLine("AssertFailed");
                    ConventionSupport.GetCurrentMethodName( );
                }

                return(bConditon);
            }
예제 #5
0
        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;
        }
예제 #6
0
 private static void ErrorDump()
 {
     ConventionSupport.GetCurrentMethodName( );
 }