+#if NET_4_5
+ public static bool IsErrorRedirected {
+ get {
+ return stderr != console_stderr || ConsoleDriver.IsErrorRedirected;
+ }
+ }
+
+ public static bool IsOutputRedirected {
+ get {
+ return stdout != console_stdout || ConsoleDriver.IsOutputRedirected;
+ }
+ }
+
+ public static bool IsInputRedirected {
+ get {
+ return stdin != console_stdin || ConsoleDriver.IsInputRedirected;
+ }
+ }
+#endif
+
+ private static Stream Open (IntPtr handle, FileAccess access, int bufferSize)
+ {
+#if MOONLIGHT
+ if (SecurityManager.SecurityEnabled && !Debugger.IsAttached && Environment.GetEnvironmentVariable ("MOONLIGHT_ENABLE_CONSOLE") == null)
+ return new NullStream ();
+#endif
+ try {
+ return new FileStream (handle, access, false, bufferSize, false, bufferSize == 0);
+ } catch (IOException) {
+ return new NullStream ();
+ }
+ }
+