コード例 #1
0
 public static String GetInternalString(Enum val)
 {
     return(StringEnum.GetStringValue(val));
 }
コード例 #2
0
        /// <summary>
        /// CAREFUL: THIS IS A __DEBUG METHOD, WORKS BEST ON __DEBUG FLAG
        /// Prints information message by code, if isError then as error string.
        /// Exits program on exit == true
        /// Optionally prints appended string
        /// </summary>
        /// <param name="code"></param>
        /// <param name="isError"></param>
        /// <param name="exit"></param>
        public static void PrintInformation(Configuration.InformationStrings code, string optstring, PrintMode mode, bool exit)
        {
            MethodBase m          = new StackTrace().GetFrame(1).GetMethod();
            string     methodName = "N/A";
            string     className  = "N/A";
            string     logMessage = "";

            if (m != null)
            {
                methodName = m.Name;
                className  = m.ReflectedType.Name;
            }

            switch (mode)
            {
            case PrintMode.ERROR:
                logMessage += "ERROR:";
#if __DEBUG
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("ERROR: ");
#endif
                break;

            case PrintMode.VARS:
                logMessage += "VARIABLES:";
#if __DEBUG
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write("VARIABLES: ");
#endif
                break;

            default:
                break;
            }

            logMessage += ":" + className + ":" + methodName + ": " + StringEnum.GetInternalString(code) + " ";


#if __DEBUG
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("{0,-35}", ":" + className + ":" + methodName + ": ");
            // Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(StringEnum.GetInternalString(code));
            //Console.ResetColor();
#endif


            if (!String.IsNullOrEmpty(optstring))
            {
#if __DEBUG
                Console.Write(optstring);
#endif
                logMessage += optstring;
            }

#if __DEBUG
            Console.Write("\n");
#endif

            logMessage += "\n";
            Logger.Logger.Log(logMessage);

            if (exit)
            {
#if __DEBUG
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("Exiting.");
#endif
                Logger.Logger.Log("Exiting.");

#if __DEBUG
                Console.ReadKey();
#endif
                Environment.Exit(0);
            }
        }