private static ulong TryGetDevicePropertyInteger(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return(device.GetPropertyInteger(propertyName)); } catch { } return(0); }
private static string TryGetDevicePropertyString(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return(device.GetPropertyString(propertyName)); } catch {} return(String.Empty); }
private static bool TryGetDevicePropertyBoolean(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return(device.GetPropertyBoolean(propertyName)); } catch { } return(false); }
private static ulong TryGetDevicePropertyInteger(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return device.GetPropertyInteger(propertyName); } catch { } return 0; }
private static bool TryGetDevicePropertyBoolean(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return device.GetPropertyBoolean(propertyName); } catch { } return false; }
private static string TryGetDevicePropertyString(IHalDevice device, string propertyName) { //if the property does not exist, we don't care try { return device.GetPropertyString(propertyName); } catch{} return String.Empty; }
private static bool DeviceIsOnUsbBus(Connection conn, string halNameOnDbus, IHalDevice device) { bool deviceIsOnUsbSubsystem; bool thereIsAPathToParent; do { string subsystem = TryGetDevicePropertyString(device, "info.subsystem"); deviceIsOnUsbSubsystem = subsystem.Contains("usb"); string pathToParent = TryGetDevicePropertyString(device, "info.parent"); thereIsAPathToParent = String.IsNullOrEmpty(pathToParent); device = conn.GetObject <IHalDevice>(halNameOnDbus, new ObjectPath(pathToParent)); } while (!deviceIsOnUsbSubsystem && !thereIsAPathToParent); return(deviceIsOnUsbSubsystem); }
private static bool DeviceIsOnUsbBus(Connection conn, string halNameOnDbus, IHalDevice device) { bool deviceIsOnUsbSubsystem; bool thereIsAPathToParent; do { string subsystem = TryGetDevicePropertyString(device, "info.subsystem"); deviceIsOnUsbSubsystem = subsystem.Contains("usb"); string pathToParent = TryGetDevicePropertyString(device, "info.parent"); thereIsAPathToParent = String.IsNullOrEmpty(pathToParent); device = conn.GetObject<IHalDevice>(halNameOnDbus, new ObjectPath(pathToParent)); } while (!deviceIsOnUsbSubsystem && !thereIsAPathToParent); return deviceIsOnUsbSubsystem; }