Beispiel #1
0
        private static ICpuIdX86 GetCpu(string fileName)
        {
            string fullPath = Path.Combine(TestResources, fileName);

            CpuIdXmlFactory factory = new CpuIdXmlFactory();
            ICpuId          cpu     = factory.Create(fullPath);
            ICpuIdX86       x86cpu  = cpu as ICpuIdX86;

            Assert.That(x86cpu, Is.Not.Null);
            Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True);
            return(x86cpu);
        }
Beispiel #2
0
        public void LoadCpu(string fileName)
        {
            CpuIdXmlFactory factory = new CpuIdXmlFactory();

            Cpu = factory.Create(fileName) as ICpuIdX86;
            if (Cpu == null)
            {
                throw new InvalidOperationException("Couldn't load CPU file");
            }

            Cpus = factory.CreateAll(fileName).OfType <ICpuIdX86>();

            Initialize();
        }
Beispiel #3
0
        private static GenericIntelCpu GetCpu(string fileName)
        {
            string fullPath = Path.Combine(TestResources, fileName);

            CpuIdXmlFactory factory = new CpuIdXmlFactory();
            ICpuId          cpu     = factory.Create(fullPath);
            GenericIntelCpu x86cpu  = cpu as GenericIntelCpu;

            Assert.That(cpu, Is.Not.Null);
            Assert.That(cpu.CpuVendor, Is.EqualTo(CpuVendor.Unknown));
            Assert.That(cpu.VendorId, Is.EqualTo("            "));
            Assert.That(x86cpu.Topology.CoreTopology.IsReadOnly, Is.True);
            Assert.That(x86cpu.Topology.CoreTopology.Count, Is.EqualTo(0));
            Assert.That(x86cpu.Topology.CacheTopology.IsReadOnly, Is.True);
            Assert.That(x86cpu.Topology.CacheTopology.Count, Is.EqualTo(0));
            return(x86cpu);
        }
Beispiel #4
0
        private void mnuFileSave_Click(object sender, EventArgs e)
        {
            if (cpuIdTree1.Cores.Count == 0)
            {
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog {
                AddExtension       = true,
                AutoUpgradeEnabled = true,
                CheckPathExists    = true,
                Filter             = "XML files (*.xml)|*.xml|All files (*.*)|*.*",
                DefaultExt         = "xml",
                OverwritePrompt    = true,
                Title         = "Save CPUID information",
                FileName      = GetDefaultFileName(),
                ValidateNames = true
            };
            DialogResult result = dlg.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(dlg.FileName))
            {
                return;
            }

            try {
                CpuIdXmlFactory.Save(dlg.FileName, cpuIdTree1.Cores);
            } catch (Exception ex) {
                string message = string.Format("Error saving file: {0}", ex.Message);
                MessageBox.Show(message, "Error Saving File");
            }
        }