public static int Main() { ICpuIdFactory cpuFactory = new CpuIdFactory(); ICpuId firstCpu = cpuFactory.Create(); IEnumerable <ICpuId> cpus = cpuFactory.CreateAll(); string fileName; if (firstCpu is CpuId.Intel.ICpuIdX86 x86cpu) { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0}{1:X07} ({2}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, Environment.MachineName); } else { fileName = string.Format("{0}{1:X07} ({2}, {3}).xml", firstCpu.VendorId, x86cpu.ProcessorSignature, firstCpu.Description, Environment.MachineName); } } else { if (string.IsNullOrWhiteSpace(firstCpu.Description)) { fileName = string.Format("{0} ({1}).xml", firstCpu.VendorId, Environment.MachineName); } else { fileName = string.Format("{0} ({1}, {2}).xml", firstCpu.VendorId, firstCpu.Description, Environment.MachineName); } } try { CpuIdXmlFactory.Save(fileName, cpus); Console.WriteLine("Wrote output to: {0}", fileName); return(0); } catch (Exception ex) { Console.WriteLine("Error writing to: {0}", fileName); Console.WriteLine(" -> {0}", ex.Message); return(1); } }
public void AllCpuId() { ICpuIdFactory factory = new CpuIdFactory(); IEnumerable <ICpuId> cpus = factory.CreateAll(); Assert.That(cpus, Is.Not.Null); int cpuNumber = 0; foreach (ICpuId cpu in cpus) { Console.WriteLine("==> CPU #{0}", cpuNumber); DumpCpu(cpu); cpuNumber++; if (cpu is CpuId.Intel.ICpuIdX86 x86cpu) { Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True); } } }