protected Volume(BlockDevice parent, Hal.Manager manager, Hal.Device device) : base(manager, device) { this.parent = parent ?? BlockDevice.Resolve <IBlockDevice> (manager, device.Parent); method_names = HalDevice.PropertyExists(method_names_property) ? device.GetPropertyStringList(method_names_property) : new string[0]; }
public IEnumerator <IVolume> GetEnumerator() { foreach (Hal.Device hal_device in HalDevice.GetChildrenAsDevice(HalManager)) { Volume volume = Volume.Resolve(this, HalManager, hal_device); if (volume != null) { yield return(volume); } } }
private static string TryGetDevicePropertyString(HalDevice device, string propertyName) { //if the property does not exist, we don't care try { return device.GetPropertyString(propertyName); } catch{} return String.Empty; }
private static ulong TryGetDevicePropertyInteger(HalDevice 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(HalDevice device, string propertyName) { //if the property does not exist, we don't care try { return device.GetPropertyBoolean(propertyName); } catch { } return false; }
private static bool DeviceIsOnUsbBus(Connection conn, string halNameOnDbus, HalDevice 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<HalDevice>(halNameOnDbus, new ObjectPath(pathToParent)); } while (!deviceIsOnUsbSubsystem && !thereIsAPathToParent); return deviceIsOnUsbSubsystem; }