using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace NTwain { /// /// Class for checking various platform requirements and conditions. /// public static class Platform { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] static Platform() { IsApp64bit = IntPtr.Size == 8; NewWinDsmExists = File.Exists(Path.Combine(Environment.SystemDirectory, "twaindsm.dll")); UseNewDSM = IsApp64bit || NewWinDsmExists; IsOnMono = Type.GetType("Mono.Runtime") != null; IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT; IsLinux = Environment.OSVersion.Platform == PlatformID.Unix; _defaultMemManager = new WinMemoryManager(); } internal static readonly bool UseNewDSM; internal static readonly bool IsApp64bit; internal static readonly bool NewWinDsmExists; internal static readonly bool IsOnMono; internal static readonly bool IsWin; internal static readonly bool IsLinux; /// /// Gets a value indicating whether this library is supported. /// /// /// true if this library is supported; otherwise, false. /// public static bool IsSupported { get { if (IsWin) { if (IsApp64bit) { return NewWinDsmExists; } return true; } return IsOnMono && IsLinux; } } static readonly IMemoryManager _defaultMemManager; static IMemoryManager _specifiedMemManager; /// /// Gets the for communicating with data sources. /// This should only be used after the DSM has been opened. /// /// /// The memory manager. /// public static IMemoryManager MemoryManager { get { if (_specifiedMemManager == null) { return _defaultMemManager; } return _specifiedMemManager; } internal set { _specifiedMemManager = value; } } } }