public PciDeviceInfo(PciVendorInfo vendor, string str) { Vendor = vendor; var tokens = str.Trim('\t').Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); DeviceID = Convert.ToUInt16(tokens[0], 16); DeviceName = tokens[1]; }
private void Load(string filepath) { ushort last_vid = 0xFFFF; ushort last_did = 0xFFFF; Initialized = false; Vendors.Clear(); if (!File.Exists(filepath)) { return; } using (var sr = new StreamReader(filepath)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); //skip empty if (string.IsNullOrWhiteSpace(line)) { continue; } //skip comments if (line[0] == '#') { continue; } //skip subvendors if (line[1] == '\t') { continue; } //device if (line[0] == '\t') { var dev = Vendors[last_vid].AddDevice(line); last_did = dev.DeviceID; continue; } //vendor var vendor = new PciVendorInfo(line); Vendors[vendor.VendorID] = vendor; last_vid = vendor.VendorID; } Initialized = true; } }