public static InputDeviceMatcher FromDeviceDescription(InputDeviceDescription deviceDescription) { var matcher = new InputDeviceMatcher(); if (!string.IsNullOrEmpty(deviceDescription.interfaceName)) { matcher = matcher.WithInterface(deviceDescription.interfaceName); } if (!string.IsNullOrEmpty(deviceDescription.deviceClass)) { matcher = matcher.WithDeviceClass(deviceDescription.deviceClass); } if (!string.IsNullOrEmpty(deviceDescription.manufacturer)) { matcher = matcher.WithManufacturer(deviceDescription.manufacturer); } if (!string.IsNullOrEmpty(deviceDescription.product)) { matcher = matcher.WithProduct(deviceDescription.product); } if (!string.IsNullOrEmpty(deviceDescription.version)) { matcher = matcher.WithVersion(deviceDescription.version); } // We don't include capabilities in this conversion. return(matcher); }
public InputDeviceMatcher ToMatcher() { var matcher = new InputDeviceMatcher(); ////TODO: get rid of the piecemeal array allocation and do it in one step // Interfaces. if (!string.IsNullOrEmpty(@interface)) { matcher = matcher.WithInterface(@interface); } if (interfaces != null) { foreach (var value in interfaces) { matcher = matcher.WithInterface(value); } } // Device classes. if (!string.IsNullOrEmpty(deviceClass)) { matcher = matcher.WithDeviceClass(deviceClass); } if (deviceClasses != null) { foreach (var value in deviceClasses) { matcher = matcher.WithDeviceClass(value); } } // Manufacturer. if (!string.IsNullOrEmpty(manufacturer)) { matcher = matcher.WithManufacturer(manufacturer); } if (manufacturers != null) { foreach (var value in manufacturers) { matcher = matcher.WithManufacturer(value); } } // Product. if (!string.IsNullOrEmpty(product)) { matcher = matcher.WithProduct(product); } if (products != null) { foreach (var value in products) { matcher = matcher.WithProduct(value); } } // Version. if (!string.IsNullOrEmpty(version)) { matcher = matcher.WithVersion(version); } if (versions != null) { foreach (var value in versions) { matcher = matcher.WithVersion(value); } } // Capabilities. if (capabilities != null) { foreach (var value in capabilities) { ////FIXME: we're turning all values into strings here matcher = matcher.WithCapability(value.path, value.value); } } return(matcher); }