Пример #1
0
        static void Main(string[] args)
        {
            Console.Write("Enter a language code for translation (empty for default): ");
            string        code         = Console.ReadLine();
            var           localization = new CultureInfo(code);
            PeriodicTable table;

            try
            {
                table = PeriodicTable.Load(localization);
                Console.WriteLine("Successfully loaded periodic table.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return;
            }
            loop(table);
        }
Пример #2
0
        public void LoadUserDefineTableInternational()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
                    <PeriodicTable>
                      <Element Name=""Hydrogen"" Symbol=""H"" AtomicNumber=""1"" AverageMass=""1,0079407538957064"" ValenceElectrons=""1"">
                        <Isotope Id=""0"" Mass=""5,00782503207"" MassNumber=""1"" Abundance=""0,999885"" />
                        <Isotope Id=""7"" Mass=""2,0141017778"" MassNumber=""2"" Abundance=""0,000115"" />
                      </Element>
                    </PeriodicTable>";

            string fileName = Path.Combine(Path.GetTempPath(), "testTableInt.xml");

            File.WriteAllText(fileName, xml);

            PeriodicTable.Load(fileName);

            File.Delete(fileName);

            Assert.AreEqual(5.00782503207, PeriodicTable.GetIsotope("H", 1).AtomicMass, 0.0000001);
        }