diff --git a/Source/OpenTK/DisplayDevice.cs b/Source/OpenTK/DisplayDevice.cs index 8f115c05..0862b76c 100644 --- a/Source/OpenTK/DisplayDevice.cs +++ b/Source/OpenTK/DisplayDevice.cs @@ -30,13 +30,14 @@ namespace OpenTK #region --- Fields --- DisplayResolution current_resolution, original_resolution; - List available_resolutions = new List(); + readonly List available_resolutions = new List(); + readonly IList available_resolutions_readonly; bool primary; - static List available_displays = new List(); - static object display_lock = new object(); + static readonly List available_displays = new List(); + static readonly IList available_displays_readonly; + static readonly object display_lock = new object(); static DisplayDevice primary_display; - //static FadeEffect effect = new FadeEffect(); static Platform.IDisplayDeviceDriver implementation; @@ -47,6 +48,7 @@ namespace OpenTK static DisplayDevice() { implementation = Platform.Factory.Default.CreateDisplayDeviceDriver(); + available_displays_readonly = available_displays.AsReadOnly(); } internal DisplayDevice(DisplayResolution currentResolution, bool primary, @@ -65,6 +67,8 @@ namespace OpenTK if (primary) primary_display = this; } + + available_resolutions_readonly = available_resolutions.AsReadOnly(); } #endregion @@ -155,21 +159,14 @@ namespace OpenTK #endregion - #region public DisplayResolution[] AvailableResolutions + #region public IList AvailableResolutions /// - /// Gets an array of OpenTK.DisplayResolution objects, which describe all available resolutions - /// for this device. + /// Gets the list of objects available on this device. /// - public DisplayResolution[] AvailableResolutions + public IList AvailableResolutions { - get - { - lock (display_lock) - { - return available_resolutions.ToArray(); - } - } + get { return available_resolutions_readonly; } } #endregion @@ -242,20 +239,14 @@ namespace OpenTK #endregion - #region public static DisplayDevice[] AvailableDisplays + #region public static IList AvailableDisplays /// - /// Gets an array of OpenTK.DisplayDevice objects, which describe all available display devices. + /// Gets the list of available objects. /// - public static DisplayDevice[] AvailableDisplays + public static IList AvailableDisplays { - get - { - lock (display_lock) - { - return available_displays.ToArray(); - } - } + get { return available_displays_readonly; } } #endregion