HDLToolkit.Framework.Devices.DeviceManager.FindPart C# (CSharp) Method

FindPart() public method

public FindPart ( string query ) : IEnumerable
query string
return IEnumerable
        public IEnumerable<object> FindPart(string query)
        {
            List<object> devices = new List<object>();
            foreach (DeviceManufacture manufacture in Manufacturers)
            {
                foreach (DeviceFamily family in manufacture.Families)
                {
                    foreach (Device device in family.Devices)
                    {
                        // does if match the device?
                        if (string.Compare(device.Name, query, true) == 0)
                        {
                            devices.Add(device);
                        }

                        foreach (DevicePart part in device.Parts)
                        {
                            // does if match the part?
                            if (string.Compare(part.Name, query, true) == 0)
                            {
                                devices.Add(part);
                            }

                            foreach (DevicePartSpeed speed in part.Speeds)
                            {
                                // does if match the part and speed?
                                if (string.Compare(speed.Name, query, true) == 0)
                                {
                                    devices.Add(speed);
                                }
                                else if (string.Compare(speed.AlternateName, query, true) == 0)
                                {
                                    devices.Add(speed);
                                }
                            }
                        }
                    }
                }
            }
            return devices;
        }

Usage Example

コード例 #1
0
        public static DevicePartSpeed FindDeviceByName(DeviceManager manager, string query)
        {
            DevicePartSpeed device = null;
            IEnumerable<object> parts = manager.FindPart(query);
            object firstPart = parts.FirstOrDefault();
            Logger.Instance.WriteVerbose("Found {0} matching device(s)", parts.Count());

            if (firstPart == null || !(firstPart is DevicePartSpeed))
            {
                return null;
            }
            device = firstPart as DevicePartSpeed;

            return device;
        }
All Usage Examples Of HDLToolkit.Framework.Devices.DeviceManager::FindPart