public void LoadDrivers(string[] librariesList, OnDriverLoadError onLoadError = null) { Drivers = new List <IBarcodeDriver>(); foreach (string libraryPath in librariesList) { string fullLibraryPath = !Path.IsPathRooted(libraryPath) ? Path.Combine(ApplicationPath, libraryPath) : libraryPath; try { Assembly assembly = Assembly.LoadFile(fullLibraryPath); foreach (Type type in assembly.GetTypes()) { if (type.GetInterfaces().FirstOrDefault(i => i == typeof(IBarcodeDriver)) != null && !type.IsInterface && !type.IsAbstract) { IBarcodeDriver processor = (IBarcodeDriver)Activator.CreateInstance(type); Drivers.Add(processor); } } } catch (Exception ex) { onLoadError?.Invoke(libraryPath, ex); } } }
private void CbBarcodeDriverSelectedIndexChanged(object sender, EventArgs e) { _barcodeDriver = cbBarcodeDriver.SelectedItem as IBarcodeDriver; tbDriverFormats.Text = _barcodeDriver?.SupportFormats ?? string.Empty; if (!_initializing) { ApplySetting(); } }