From 86bf6efe34c793bd55901ac144f8cd3bfef30be9 Mon Sep 17 00:00:00 2001
From: Eugene Wang <yinchun.wang@gmail.com>
Date: Thu, 27 Aug 2015 05:34:21 -0400
Subject: [PATCH] Also added GetValuesRaw() to capabilities class.

---
 src/NTwain/CapWrapper.cs             | 10 +---------
 src/NTwain/Capabilities.cs           | 20 ++++++++++++++++++++
 src/NTwain/CapabilityReader.cs       |  6 +++---
 src/NTwain/Properties/VersionInfo.cs |  2 +-
 4 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/src/NTwain/CapWrapper.cs b/src/NTwain/CapWrapper.cs
index eebd6db..d8a9d44 100644
--- a/src/NTwain/CapWrapper.cs
+++ b/src/NTwain/CapWrapper.cs
@@ -308,15 +308,7 @@ namespace NTwain
         /// <returns></returns>
         public CapabilityReader GetValuesRaw()
         {
-            using (TWCapability cap = new TWCapability(Capability))
-            {
-                var rc = _source.DGControl.Capability.Get(cap);
-                if (rc == ReturnCode.Success)
-                {
-                    return CapabilityReader.ReadValue(cap);
-                }
-            }
-            return null;
+            return _source.Capabilities.GetValuesRaw(Capability);
         }
 
         /// <summary>
diff --git a/src/NTwain/Capabilities.cs b/src/NTwain/Capabilities.cs
index b117543..9b08139 100644
--- a/src/NTwain/Capabilities.cs
+++ b/src/NTwain/Capabilities.cs
@@ -147,6 +147,26 @@ namespace NTwain
             return Enumerable.Empty<object>();
         }
 
+        /// <summary>
+        /// Gets all the possible values of this capability without expanding.
+        /// This may be required to work with large range values that cannot be safely enumerated
+        /// with <see cref="GetValues"/>.
+        /// </summary>
+        /// <param name="capabilityId">The capability id.</param>
+        /// <returns></returns>
+        public CapabilityReader GetValuesRaw(CapabilityId capabilityId)
+        {
+            using (TWCapability cap = new TWCapability(capabilityId))
+            {
+                var rc = _source.DGControl.Capability.Get(cap);
+                if (rc == ReturnCode.Success)
+                {
+                    return CapabilityReader.ReadValue(cap);
+                }
+            }
+            return new CapabilityReader();
+        }
+
         /// <summary>
         /// Resets all values and constraint to power-on defaults.
         /// </summary>
diff --git a/src/NTwain/CapabilityReader.cs b/src/NTwain/CapabilityReader.cs
index 988aae2..9633427 100644
--- a/src/NTwain/CapabilityReader.cs
+++ b/src/NTwain/CapabilityReader.cs
@@ -123,7 +123,7 @@ namespace NTwain
         public ItemType ItemType { get; private set; }
 
         /// <summary>
-        /// Gets the one value if container is <see cref="NTwain.Data.ContainerType.Array"/>.
+        /// Gets the one value if container is <see cref="NTwain.Data.ContainerType.OneValue"/>.
         /// </summary>
         /// <value>
         /// The one value.
@@ -280,7 +280,7 @@ namespace NTwain
                         }
                     }
                     break;
-                // these should never happen since TW_ENUM fields are 4 bytes but you never know
+                // these should never happen since TW_RANGE fields are 4 bytes but you never know
                 case Data.ItemType.UInt16:
                     {
                         var min = (ushort)RangeMinValue;
@@ -439,7 +439,7 @@ namespace NTwain
                         RangeCount = ((max - min) / step) + 1;
                     }
                     break;
-                // these should never happen since TW_ENUM fields are 4 bytes but you never know
+                // these should never happen since TW_RANGE fields are 4 bytes but you never know
                 case Data.ItemType.UInt16:
                     {
                         var min = (ushort)RangeMinValue;
diff --git a/src/NTwain/Properties/VersionInfo.cs b/src/NTwain/Properties/VersionInfo.cs
index 3e1a861..19d11c9 100644
--- a/src/NTwain/Properties/VersionInfo.cs
+++ b/src/NTwain/Properties/VersionInfo.cs
@@ -23,7 +23,7 @@ namespace NTwain
         /// <summary>
         /// The build release version number.
         /// </summary>
-        public const string Build = "3.3.6"; // change this for each nuget release
+        public const string Build = "3.3.7"; // change this for each nuget release
 
 
     }