[Input] Added From* overloads with out parameters
authorthefiddler <stapostol@gmail.com>
Wed, 17 Sep 2014 16:15:05 +0000 (18:15 +0200)
committerthefiddler <stapostol@gmail.com>
Wed, 17 Sep 2014 23:16:40 +0000 (01:16 +0200)
Source/OpenTK/Platform/DeviceCollection.cs

index 04ac101..804dac9 100644 (file)
@@ -115,6 +115,20 @@ namespace OpenTK.Platform
             }
         }
 
+        public bool FromIndex(int index, out T device)
+        {
+            if (index >= 0 && index < Devices.Count)
+            {
+                device = Devices[index];
+                return true;
+            }
+            else
+            {
+                device = default(T);
+                return false;
+            }
+        }
+
         public T FromHardwareId(long id)
         {
             if (Map.ContainsKey(id))
@@ -127,6 +141,20 @@ namespace OpenTK.Platform
             }
         }
 
+        public bool FromHardwareId(long id, out T device)
+        {
+            if (Map.ContainsKey(id))
+            {
+                device = FromIndex(Map[id]);
+                return true;
+            }
+            else
+            {
+                device = default(T);
+                return false;
+            }
+        }
+
         public int Count
         {
             get { return Map.Count; }