/// <summary>
        /// Creates a new <see cref="iDeviceHandle"/> from a <see cref="IntPtr"/>.
        /// </summary>
        /// <param name="unsafeHandle">
        /// The underlying <see cref="IntPtr"/>
        /// </param>
        /// <param name="ownsHandle">
        /// <see langword="true"/> to reliably release the handle during the finalization phase; <see langword="false"/> to prevent reliable release (not recommended).
        /// </param>
        /// <returns>
        /// </returns>
        public static iDeviceHandle DangerousCreate(System.IntPtr unsafeHandle, bool ownsHandle)
        {
            iDeviceHandle safeHandle = new iDeviceHandle(ownsHandle);

            safeHandle.SetHandle(unsafeHandle);
            return(safeHandle);
        }
        /// <summary>
        /// Set up a connection to the given device.
        /// </summary>
        /// <param name="device">
        /// The device to connect to.
        /// </param>
        /// <param name="port">
        /// The destination port to connect to.
        /// </param>
        /// <param name="connection">
        /// Pointer to an idevice_connection_t that will be filled
        /// with the necessary data of the connection.
        /// </param>
        /// <returns>
        /// IDEVICE_E_SUCCESS if ok, otherwise an error code.
        /// </returns>
        public virtual iDeviceError idevice_connect(iDeviceHandle device, ushort port, out iDeviceConnectionHandle connection)
        {
            iDeviceError returnValue;

            returnValue    = iDeviceNativeMethods.idevice_connect(device, port, out connection);
            connection.Api = this.Parent;
            return(returnValue);
        }
        /// <summary>
        /// Creates an idevice_t structure for the device specified by udid,
        /// if the device is available.
        /// </summary>
        /// <param name="device">
        /// Upon calling this function, a pointer to a location of type
        /// idevice_t. On successful return, this location will be populated.
        /// </param>
        /// <param name="udid">
        /// The UDID to match.
        /// </param>
        /// <returns>
        /// IDEVICE_E_SUCCESS if ok, otherwise an error code.
        /// </returns>
        /// <remarks>
        /// The resulting idevice_t structure has to be freed with
        /// idevice_free() if it is no longer used.
        /// </remarks>
        public virtual iDeviceError idevice_new(out iDeviceHandle device, string udid)
        {
            iDeviceError returnValue;

            returnValue = iDeviceNativeMethods.idevice_new(out device, udid);
            device.Api  = this.Parent;
            return(returnValue);
        }
        /// <summary>
        /// Creates an idevice_t structure for the device specified by UDID,
        /// if the device is available, with the given lookup options.
        /// </summary>
        /// <param name="device">
        /// Upon calling this function, a pointer to a location of type
        /// idevice_t. On successful return, this location will be populated.
        /// </param>
        /// <param name="udid">
        /// The UDID to match.
        /// </param>
        /// <param name="options">
        /// Specifies what connection types should be considered
        /// when looking up devices. Accepts bitwise or'ed values of idevice_options.
        /// If 0 (no option) is specified it will default to IDEVICE_LOOKUP_USBMUX.
        /// To lookup both USB and network-connected devices, pass
        /// IDEVICE_LOOKUP_USBMUX | IDEVICE_LOOKUP_NETWORK. If a device is available
        /// both via USBMUX *and* network, it will select the USB connection.
        /// This behavior can be changed by adding IDEVICE_LOOKUP_PREFER_NETWORK
        /// to the options in which case it will select the network connection.
        /// </param>
        /// <returns>
        /// IDEVICE_E_SUCCESS if ok, otherwise an error code.
        /// </returns>
        /// <remarks>
        /// The resulting idevice_t structure has to be freed with
        /// idevice_free() if it is no longer used.
        /// </remarks>
        public virtual iDeviceError idevice_new_with_options(out iDeviceHandle device, string udid, int options)
        {
            iDeviceError returnValue;

            returnValue = iDeviceNativeMethods.idevice_new_with_options(out device, udid, options);
            device.Api  = this.Parent;
            return(returnValue);
        }
        public static iDeviceError idevice_get_udid(iDeviceHandle device, out string udid)
        {
            System.Runtime.InteropServices.ICustomMarshaler udidMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr udidNative  = System.IntPtr.Zero;
            iDeviceError  returnValue = iDeviceNativeMethods.idevice_get_udid(device, out udidNative);

            udid = ((string)udidMarshaler.MarshalNativeToManaged(udidNative));
            udidMarshaler.CleanUpNativeData(udidNative);
            return(returnValue);
        }
 public static extern iDeviceError idevice_get_udid(iDeviceHandle device, out System.IntPtr udid);
 public static extern iDeviceError idevice_get_handle(iDeviceHandle device, ref uint handle);
 public static extern iDeviceError idevice_connect(iDeviceHandle device, ushort port, out iDeviceConnectionHandle connection);
 public static extern iDeviceError idevice_new(out iDeviceHandle device, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string udid);
 /// <summary>
 /// Gets the unique id for the device.
 /// </summary>
 public virtual iDeviceError idevice_get_udid(iDeviceHandle device, out string udid)
 {
     return(iDeviceNativeMethods.idevice_get_udid(device, out udid));
 }
 /// <summary>
 /// Gets the handle of the device. Depends on the connection type.
 /// </summary>
 public virtual iDeviceError idevice_get_handle(iDeviceHandle device, ref uint handle)
 {
     return(iDeviceNativeMethods.idevice_get_handle(device, ref handle));
 }