コード例 #1
0
        static StringRingHistory history = new StringRingHistory(32); // keep last n-strings

        internal static string MessageObjectToString(object message)
        {
            if (message == null)
            {
                return("null (null message, maybe a format which is unsupported?)");
            }
            if (message is string stringMessage)
            {
                return(stringMessage);
            }
            if (message is int intMessage)
            {
                return(intMessage.ToString());
            }
            if (message is short shortMessage)
            {
                return(shortMessage.ToString());
            }
            if (message is float floatMessage)
            {
                return(NumberConverter.FloatToString(floatMessage));
            }
            if (message is double doubleMessage)
            {
                return(NumberConverter.DoubleToString(doubleMessage));
            }
            if (message is Exception exc)
            {
                return(string.Concat(exc.Message, "\n", exc.StackTrace));
            }

            return("Non-Trivially-Stringable OBJECT logged (Not supported in DOTS C#)");
        }