/// <summary> /// Builds the final configuration object. /// </summary> /// <returns></returns> public TwainConfig Build() { var config = new TwainConfig(_platform, _32bit); // todo: change id based on platform switch (_platform) { case PlatformID.Win32NT: config.App32 = new TW_IDENTITY { DataFlags = DataFlags.App2, DataGroup = DataGroups.Control | _dg, Manufacturer = _companyName ?? "Unknown", ProductFamily = _appName ?? "Unknown", ProductName = _appName ?? "Unknown", ProtocolMajor = TwainConst.ProtocolMajor, ProtocolMinor = TwainConst.ProtocolMinor, Version = new TW_VERSION { Country = _country, Language = _lang, Major = (short)_version.Major, Minor = (short)_version.Minor, Info = "" }, }; break; case PlatformID.Unix: case PlatformID.MacOSX: default: throw new PlatformNotSupportedException(string.Format(MsgText.PlatformNotSupported, _platform)); } return(config); }
/// <summary> /// Constructs a new <see cref="TwainSession"/>. /// </summary> /// <param name="config"></param> /// <exception cref="ArgumentNullException"></exception> public TwainSession(TwainConfig config) { Config = config ?? throw new ArgumentNullException(nameof(config)); SetSynchronizationContext(SynchronizationContext.Current); switch (config.Platform) { case PlatformID.MacOSX: case PlatformID.Unix: _internalContext = new DispatcherLoop(this); break; default: _internalContext = new WinMsgLoop(this); _callback32Delegate = new Callback32(Handle32BitCallback); break; } //CapReader = new CapReader(this); CapWriter = new CapWriter(config); }
/// <summary> /// Creates a new <see cref="CapWriter"/>. /// </summary> /// <param name="config"></param> internal CapWriter(TwainConfig config) { this.config = config; }