private void NativeDiskDisappeared(IntPtr disk, IntPtr context) { if (this.DeviceDisappeared == null) { // if no-one subscribed to this event, do nothing return; } IntPtr device = DiskArbitration.DADiskCopyIOMedia(disk); IntPtr propertiesRef = DiskArbitration.DADiskCopyDescription(disk); NSDictionary properties = new NSDictionary(propertiesRef); DeviceArguments deviceArguments = new DeviceArguments(properties, this); if (properties.HasKey("DADeviceProtocol") && properties.GetStringValue("DADeviceProtocol") == "USB") { OsxUsbData usb = new OsxUsbData(device); deviceArguments.UsbInfo = usb; } IOKit.IOObjectRelease(device); this.DeviceDisappeared(this, deviceArguments); GC.KeepAlive(this); }
private void NativeDiskChanged(IntPtr disk, IntPtr keys, IntPtr context) { if (this.DeviceChanged == null) { // if no-one subscribed to this event, do nothing return; } IntPtr device = DiskArbitration.DADiskCopyIOMedia(disk); IntPtr propertiesRef = DiskArbitration.DADiskCopyDescription(disk); // using MonoMac we can get a managed NSDictionary from the pointer NSDictionary properties = new NSDictionary(propertiesRef); DeviceArguments deviceArguments = new DeviceArguments(properties, this); if (properties.HasKey("DADeviceProtocol") && properties.GetStringValue("DADeviceProtocol") == "USB") { OsxUsbData usb = new OsxUsbData(device); deviceArguments.UsbInfo = usb; } IOKit.IOObjectRelease(device); // trigger the public event for any subscribers this.DeviceChanged(this, deviceArguments); GC.KeepAlive(this); }
private void NativeDiskDisappeared(IntPtr disk, IntPtr context) { if (this.DeviceDisappeared == null) { // if no-one subscribed to this event, do nothing return; } IntPtr device = DiskArbitration.DADiskCopyIOMedia (disk); IntPtr propertiesRef = DiskArbitration.DADiskCopyDescription (disk); NSDictionary properties = new NSDictionary (propertiesRef); DeviceArguments deviceArguments = new DeviceArguments (properties, this); if (properties.HasKey ("DADeviceProtocol") && properties.GetStringValue ("DADeviceProtocol") == "USB") { OsxUsbData usb = new OsxUsbData (device); deviceArguments.UsbInfo = usb; } IOKit.IOObjectRelease (device); this.DeviceDisappeared (this, deviceArguments); GC.KeepAlive (this); }
private void NativeDiskChanged(IntPtr disk, IntPtr keys, IntPtr context) { if (this.DeviceChanged == null) { // if no-one subscribed to this event, do nothing return; } IntPtr device = DiskArbitration.DADiskCopyIOMedia (disk); IntPtr propertiesRef = DiskArbitration.DADiskCopyDescription (disk); // using MonoMac we can get a managed NSDictionary from the pointer NSDictionary properties = new NSDictionary (propertiesRef); DeviceArguments deviceArguments = new DeviceArguments (properties, this); if (properties.HasKey ("DADeviceProtocol") && properties.GetStringValue ("DADeviceProtocol") == "USB") { OsxUsbData usb = new OsxUsbData (device); deviceArguments.UsbInfo = usb; } IOKit.IOObjectRelease (device); // trigger the public event for any subscribers this.DeviceChanged (this, deviceArguments); GC.KeepAlive (this); }