Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public DeviceArguments(NSDictionary properties, OsxUsbData usbdata)
     : this(properties)
 {
     UsbInfo = usbdata;
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public DeviceArguments(NSDictionary properties, OsxUsbData usbdata) : this(properties)
 {
     UsbInfo = usbdata;
 }