fCraft.Logger.LogToConsole C# (CSharp) Method

LogToConsole() public static method

public static LogToConsole ( [ message ) : void
message [
return void
        public static void LogToConsole( [NotNull] string message )
        {
            if ( message == null )
                throw new ArgumentNullException( "message" );
            if ( message.Contains( '\n' ) ) {
                foreach ( string line in message.Split( '\n' ) ) {
                    LogToConsole( line );
                }
                return;
            }
            string processedMessage = "# ";
            for ( int i = 0; i < message.Length; i++ ) {
                if ( message[i] == '&' )
                    i++;
                else
                    processedMessage += message[i];
            }
            Log( LogType.ConsoleOutput, processedMessage );
        }

Usage Example

Example #1
0
        //differentiates the same way humans do, with visual shortcuts
        static string differentiate(string inString, string expression)
        {
            if (inString == "+" || inString == "-")
            {
                Logger.LogToConsole("0");
                return(inString);
            }

            Regex numberPolyRegex = new Regex(@"[0-9]+x\^[0-9]+"); //nx^c
            Regex polyRegex       = new Regex(@"x\^[0-9]+");       //x^n
            Regex linearRegex     = new Regex(@"[0-9]+x");         //nx

            if (numberPolyRegex.IsMatch(expression))
            {
                Logger.LogToConsole("1");
                int coefficient = Convert.ToInt32(inString.Substring(0, inString.IndexOf("x")));
                int exp         = Convert.ToInt32(inString.Substring(inString.IndexOf("x") + 2));
                return(exp * coefficient + "x^" + (exp - 1));
            }
            else if (polyRegex.IsMatch(expression))
            {
                Logger.LogToConsole("2");
                int exp = Convert.ToInt32(inString.Substring(2));
                return(exp + "x^" + (exp - 1));
            }
            else if (linearRegex.IsMatch(expression))
            {
                Logger.LogToConsole("3");
                Logger.LogToConsole(inString.Length.ToString());
                Logger.LogToConsole(inString.IndexOf("x").ToString());
                return(inString.Substring(0, inString.IndexOf("x")));
            }

            return("0");
        }
All Usage Examples Of fCraft.Logger::LogToConsole