public DeviceDriver FindDriver(IPCIDevice pciDevice)
{
DeviceDriver bestDeviceDriver = null;
int bestPriority = int.MaxValue;
foreach (var deviceDriver in deviceDrivers)
{
if (deviceDriver.Attribute is PCIDeviceDriverAttribute)
{
var pciDeviceDriverAttribute = deviceDriver.Attribute as PCIDeviceDriverAttribute;
if ((pciDeviceDriverAttribute.Priority != 0) && (pciDeviceDriverAttribute.Priority < bestPriority))
{
if (pciDeviceDriverAttribute.CompareTo(pciDevice))
{
bestDeviceDriver = deviceDriver;
bestPriority = pciDeviceDriverAttribute.Priority;
}
}
}
}
return bestDeviceDriver;
}