public static void SetIn(TextReader newIn)
        {
            if (newIn == null)
            {
                throw new ArgumentNullException("newIn");
            }

            stdin = newIn;
        }
        private static void SetupStreams(Encoding inputEncoding, Encoding outputEncoding)
        {
#if !NET_2_1 && !SSHARP
            if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole)
            {
                StreamWriter w = new CStreamWriter(OpenStandardOutput(0), outputEncoding);
                w.AutoFlush = true;
                stdout      = TextWriter.Synchronized(w, true);

                w           = new CStreamWriter(OpenStandardOutput(0), outputEncoding);
                w.AutoFlush = true;
                stderr      = TextWriter.Synchronized(w, true);

#if CONSOLEIN
                stdin = new CStreamReader(OpenStandardInput(0), inputEncoding);
#endif
            }
            else
            {
#endif
// FULL_AOT_RUNTIME is used (instead of MONOTOUCH) since we only want this code when running on
// iOS (simulator or devices) and *not* when running tools (e.g. btouch #12179) that needs to use
// the mscorlib.dll shipped with Xamarin.iOS
#if MONOTOUCH && FULL_AOT_RUNTIME
            stdout = new NSLogWriter();
#else
#if SSHARP
            stdout = new StdTextWriter();
#else
            stdout = new UnexceptionalStreamWriter(OpenStandardOutput(0), outputEncoding);
            ((StreamWriter)stdout).AutoFlush = true;
#endif
#endif
            stdout = TextWriter.Synchronized(stdout, true);

#if MONOTOUCH && FULL_AOT_RUNTIME
            stderr = new NSLogWriter();
#else
#if SSHARP
            stderr = new StdErrWriter();
#else
            stderr = new UnexceptionalStreamWriter(OpenStandardError(0), outputEncoding);
            ((StreamWriter)stderr).AutoFlush = true;
#endif
#endif
            stderr = TextWriter.Synchronized(stderr, true);

#if CONSOLEIN
            stdin = new UnexceptionalStreamReader(OpenStandardInput(0), inputEncoding);
            stdin = TextReader.Synchronized(stdin);
#endif
#if !NET_2_1 && !SSHARP
        }
#endif

#if MONODROID
            if (LogcatTextWriter.IsRunningOnAndroid())
            {
                stdout = TextWriter.Synchronized(new LogcatTextWriter("mono-stdout", stdout));
                stderr = TextWriter.Synchronized(new LogcatTextWriter("mono-stderr", stderr));
            }
#endif // MONODROID

            GC.SuppressFinalize(stdout);
            GC.SuppressFinalize(stderr);
#if CONSOLEIN
            GC.SuppressFinalize(stdin);
#endif

#if SSHARP
            IsOutputRedirected = false;
            IsErrorRedirected  = false;
#endif
        }