Beispiel #1
0
        public static string GetText(this CAError code, object[] args)
        {
            var codeString = code.ToString();

            var memInfo = typeof(CAError).GetMember(codeString);

            if (memInfo == null || memInfo.Length == 0)
            {
                return(codeString);
            }

            var attrib = memInfo[0].GetCustomAttributes(typeof(ErrorMessageAttribute), false);

            if (attrib == null || attrib.Length == 0)
            {
                return(codeString);
            }

            var message = ((ErrorMessageAttribute)attrib[0]).Message;

            if (args != null && args.Length > 0)
            {
                message = string.Format(message, args);
            }
            return(string.Concat(codeString, ": ", message));
        }
Beispiel #2
0
        public static ErrorType GetErrorType(this CAError code)
        {
            var memInfo = typeof(CAError).GetMember(code.ToString());

            if (memInfo == null || memInfo.Length == 0)
            {
                return(ErrorType.Error);
            }

            var attrib = memInfo[0].GetCustomAttributes(typeof(WarningAttribute), false);

            if (attrib == null || attrib.Length == 0)
            {
                return(ErrorType.Error);
            }

            return(ErrorType.Warning);
        }