/// <summary>
 /// Gets the <see cref="IInputDeviceInstance"/> specifid by the given <see cref="IEmulatedPortDeviceEntry"/>
 /// if it is connected to the system, or null if it does not.
 /// </summary>
 /// <param name="this">The <see cref="IDeviceEnumerator"/> to use.</param>
 /// <param name="portDevice">The <see cref="IEmulatedPortDeviceEntry"/> to check if connected.</param>
 /// <returns>The <see cref="IInputDeviceInstance"/> specifid by the given <see cref="IEmulatedPortDeviceEntry"/>
 /// if it is connected to the system, or null if it does not.</returns>
 public static IInputDeviceInstance?GetPortDeviceInstance(this IDeviceEnumerator @this,
                                                          IEmulatedPortDeviceEntry portDevice)
 {
     return(@this.QueryConnectedDevices()
            .FirstOrDefault(d => d.InstanceGuid == portDevice.InstanceGuid)?.Instances?
            .FirstOrDefault(i => i.Driver == portDevice.Driver));
 }
 /// <summary>
 /// Checks if the <see cref="IInputDeviceInstance"/> specified by the given
 /// <see cref="IEmulatedPortDeviceEntry"/> is connected to the system.
 /// </summary>
 /// <param name="this">The <see cref="IDeviceEnumerator"/> to use.</param>
 /// <param name="portDevice">The <see cref="IEmulatedPortDeviceEntry"/> to check if connected.</param>
 /// <returns>Whether or not the given <see cref="IEmulatedPortDeviceEntry"/> is connected.</returns>
 public static bool IsPortDeviceConnected(this IDeviceEnumerator @this,
                                          IEmulatedPortDeviceEntry portDevice)
 {
     return(@this.QueryConnectedDevices().Any(d => d.InstanceGuid == portDevice.InstanceGuid));
 }