Пример #1
0
        static void SetupStreams(Encoding inputEncoding, Encoding outputEncoding)
        {
#if !NET_2_1
            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);

                stdin = new CStreamReader(OpenStandardInput(0), inputEncoding);
            }
            else
            {
#endif
#if FULL_AOT_RUNTIME
            Type nslogwriter = Type.GetType("MonoTouch.Foundation.NSLogWriter, monotouch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
            stdout = (TextWriter)Activator.CreateInstance(nslogwriter);
#else
            stdout = new UnexceptionalStreamWriter(OpenStandardOutput(0), outputEncoding);
            ((StreamWriter)stdout).AutoFlush = true;
#endif
            stdout = TextWriter.Synchronized(stdout, true);

#if FULL_AOT_RUNTIME
            stderr = (TextWriter)Activator.CreateInstance(nslogwriter);
#else
            stderr = new UnexceptionalStreamWriter(OpenStandardError(0), outputEncoding);
            ((StreamWriter)stderr).AutoFlush = true;
#endif
            stderr = TextWriter.Synchronized(stderr, true);

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

#if NET_4_5
            console_stderr = stderr;
            console_stdout = stdout;
            console_stdin  = stdin;
#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);
            GC.SuppressFinalize(stdin);
        }
Пример #2
0
        static void SetupStreams(Encoding inputEncoding, Encoding outputEncoding)
        {
#if !NET_2_1
            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);

                stdin = new CStreamReader(OpenStandardInput(0), inputEncoding);
            }
            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
            stdout = new UnexceptionalStreamWriter(OpenStandardOutput(0), outputEncoding);
            ((StreamWriter)stdout).AutoFlush = true;
#endif
            stdout = TextWriter.Synchronized(stdout, true);

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

            stdin = new UnexceptionalStreamReader(OpenStandardInput(0), inputEncoding);
            stdin = TextReader.Synchronized(stdin);
#if !NET_2_1
        }
#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);
            GC.SuppressFinalize(stdin);
        }
Пример #3
0
        static void SetupStreams(Encoding inputEncoding, Encoding outputEncoding)
        {
#if !NET_2_1
            if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole)
            {
                StreamWriter w = new CStreamWriter(OpenStandardOutput(0), outputEncoding, true);
                w.AutoFlush = true;
                stdout      = TextWriter.Synchronized(w);

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

                stdin = new CStreamReader(OpenStandardInput(0), inputEncoding);
            }
            else
            {
#endif
#if MONOTOUCH
            stdout = new NSLogWriter();
#else
            stdout = new UnexceptionalStreamWriter(OpenStandardOutput(0), outputEncoding);
            ((StreamWriter)stdout).AutoFlush = true;
#endif
            stdout = TextWriter.Synchronized(stdout);

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

            stdin = new UnexceptionalStreamReader(OpenStandardInput(0), inputEncoding);
            stdin = TextReader.Synchronized(stdin);
#if !NET_2_1
        }
#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);
            GC.SuppressFinalize(stdin);
        }
Пример #4
0
        static void SetupStreams(Encoding inputEncoding, Encoding outputEncoding)
        {
#if MONO_FEATURE_CONSOLE
            if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole)
            {
                stdin  = new CStreamReader(OpenStandardInput(0), inputEncoding);
                stdout = TextWriter.Synchronized(new CStreamWriter(OpenStandardOutput(0), outputEncoding, true)
                {
                    AutoFlush = true
                });
                stderr = TextWriter.Synchronized(new CStreamWriter(OpenStandardError(0), outputEncoding, true)
                {
                    AutoFlush = true
                });
            }
            else
#endif
            {
                stdin = TextReader.Synchronized(new UnexceptionalStreamReader(OpenStandardInput(0), inputEncoding));

#if MONOTOUCH
                stdout = new NSLogWriter();
                stderr = new NSLogWriter();
#else
                stdout = TextWriter.Synchronized(new UnexceptionalStreamWriter(OpenStandardOutput(0), outputEncoding)
                {
                    AutoFlush = true
                });
                stderr = TextWriter.Synchronized(new UnexceptionalStreamWriter(OpenStandardError(0), outputEncoding)
                {
                    AutoFlush = true
                });

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

            GC.SuppressFinalize(stdout);
            GC.SuppressFinalize(stderr);
            GC.SuppressFinalize(stdin);
        }