diff --git a/NTwain/CapabilityReader.cs b/NTwain/CapabilityReader.cs index 2a63f93..994e81f 100644 --- a/NTwain/CapabilityReader.cs +++ b/NTwain/CapabilityReader.cs @@ -35,55 +35,61 @@ namespace NTwain /// The capability. /// The memory manager. /// - /// capability + /// + /// capability /// or - /// platformInfo - /// Capability contains no data.;capability - /// or - /// capability + /// memoryManager + /// + /// capability public static CapabilityReader ReadValue(TWCapability capability, IMemoryManager memoryManager) { if (capability == null) { throw new ArgumentNullException("capability"); } - if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); } if (memoryManager == null) { throw new ArgumentNullException("memoryManager"); } - IntPtr baseAddr = IntPtr.Zero; - try + if (capability.Container != IntPtr.Zero) { - baseAddr = memoryManager.Lock(capability.Container); - switch (capability.ContainerType) + IntPtr baseAddr = IntPtr.Zero; + try { - case ContainerType.Array: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadArrayValue(baseAddr); - case ContainerType.Enum: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadEnumValue(baseAddr); - case ContainerType.OneValue: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadOneValue(baseAddr); - case ContainerType.Range: - return new CapabilityReader - { - ContainerType = capability.ContainerType, - }.ReadRangeValue(baseAddr); - default: - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.CapHasBadContainer, capability.ContainerType), "capability"); + baseAddr = memoryManager.Lock(capability.Container); + switch (capability.ContainerType) + { + case ContainerType.Array: + return new CapabilityReader + { + ContainerType = capability.ContainerType, + }.ReadArrayValue(baseAddr); + case ContainerType.Enum: + return new CapabilityReader + { + ContainerType = capability.ContainerType, + }.ReadEnumValue(baseAddr); + case ContainerType.OneValue: + return new CapabilityReader + { + ContainerType = capability.ContainerType, + }.ReadOneValue(baseAddr); + case ContainerType.Range: + return new CapabilityReader + { + ContainerType = capability.ContainerType, + }.ReadRangeValue(baseAddr); + default: + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.CapHasBadContainer, capability.ContainerType), "capability"); + } + } + finally + { + if (baseAddr != IntPtr.Zero) + { + //memoryManager.Unlock(baseAddr); + memoryManager.Unlock(capability.Container); + } } } - finally + else { - if (baseAddr != IntPtr.Zero) - { - //memoryManager.Unlock(baseAddr); - memoryManager.Unlock(capability.Container); - } + return new CapabilityReader(); } } diff --git a/NTwain/Properties/VersionInfo.cs b/NTwain/Properties/VersionInfo.cs index 5d77699..e52073d 100644 --- a/NTwain/Properties/VersionInfo.cs +++ b/NTwain/Properties/VersionInfo.cs @@ -23,7 +23,7 @@ namespace NTwain /// /// The build release version number. /// - public const string Build = "3.2.8"; // change this for each nuget release + public const string Build = "3.3.0"; // change this for each nuget release }