Added RunningOnMono property.

Made Configuration class public.
This commit is contained in:
the_fiddler 2008-11-18 19:14:01 +00:00
parent 5de00a6b54
commit fbbc836394

View file

@ -17,14 +17,14 @@ using System.IO;
namespace OpenTK namespace OpenTK
{ {
/// <internal /> /// <summary>Provides information about the underlying OS and runtime.</summary>
/// <summary>Contains configuration options for OpenTK.</summary> public static class Configuration
internal static class Configuration
{ {
static bool runningOnWindows, runningOnX11, runningOnOSX, runningOnLinux; static bool runningOnWindows, runningOnX11, runningOnOSX, runningOnLinux, runningOnMono;
#region --- Constructors --- #region --- Constructors ---
// Detects the underlying OS and runtime.
static Configuration() static Configuration()
{ {
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT || if (System.Environment.OSVersion.Platform == PlatformID.Win32NT ||
@ -57,37 +57,51 @@ namespace OpenTK
} }
else else
throw new PlatformNotSupportedException("Unknown platform. Please report this error at http://www.opentk.com."); throw new PlatformNotSupportedException("Unknown platform. Please report this error at http://www.opentk.com.");
// Detect the Mono runtime (code taken from http://mono.wikia.com/wiki/Detecting_if_program_is_running_in_Mono).
Type t = Type.GetType("Mono.Runtime");
if (t != null)
runningOnMono = true;
} }
#endregion #endregion
#region --- Public Methods --- #region --- Public Methods ---
#region internal static bool RunningOnWindows #region public static bool RunningOnWindows
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on a Windows platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on a Windows platform.</summary>
internal static bool RunningOnWindows { get { return runningOnWindows; } } public static bool RunningOnWindows { get { return runningOnWindows; } }
#endregion #endregion
#region internal static bool RunningOnX11 #region public static bool RunningOnX11
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary>
internal static bool RunningOnX11 { get { return runningOnX11; } } public static bool RunningOnX11 { get { return runningOnX11; } }
#endregion #endregion
#region internal static bool RunningOnLinux #region public static bool RunningOnLinux
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary>
internal static bool RunningOnLinux { get { return runningOnLinux; } } public static bool RunningOnLinux { get { return runningOnLinux; } }
#endregion #endregion
#region internal static bool RunningOnOSX #region public static bool RunningOnOSX
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on an OSX platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on a MacOS platform.</summary>
internal static bool RunningOnOSX { get { return runningOnOSX; } } public static bool RunningOnOSX { get { return runningOnOSX; } }
#endregion
#region public static bool RunningOnMono
/// <summary>
/// Gets a System.Boolean indicating whether OpenTK is running on the Mono runtime.
/// </summary>
public static bool RunningOnMono { get { return runningOnMono; } }
#endregion #endregion
@ -95,12 +109,12 @@ namespace OpenTK
#region private static string DetectUnixKernel() #region private static string DetectUnixKernel()
/// <summary> // <summary>
/// Executes "uname" which returns a string representing the name of the // Executes "uname" which returns a string representing the name of the
/// underlying Unix kernel. // underlying Unix kernel.
/// </summary> // </summary>
/// <returns>"Unix", "Linux", "Darwin" or null.</returns> // <returns>"Unix", "Linux", "Darwin" or null.</returns>
/// <remarks>Source code from "Mono: A Developer's Notebook"</remarks> // <remarks>Source code from "Mono: A Developer's Notebook"</remarks>
private static string DetectUnixKernel() private static string DetectUnixKernel()
{ {
ProcessStartInfo startInfo = new ProcessStartInfo(); ProcessStartInfo startInfo = new ProcessStartInfo();