コード例 #1
0
 public MathGenerator GetMathGen(string _mname)
 {
     if (mMathGens.ContainsKey(_mname))
     {
         MathGenerator mathgen = new MathGenerator();
         mathgen.LoadParameters();
         return(mathgen);
     }
     return(null);
 }
コード例 #2
0
        /// <summary>
        /// Load all MathGens from XML
        /// </summary>
        public void LoadAll()
        {
            try
            {
                XPathDocument     xPathDoc      = new XPathDocument(mathStoreFile);
                XPathNavigator    navigator     = xPathDoc.CreateNavigator();
                XPathNodeIterator xPathIterator = navigator.Select("/ScanevaMathGensStore/MathGen");

                var ns = new XmlSerializerNamespaces();
                ns.Add("", "");
                XmlSerializer ser = new XmlSerializer(typeof(MathGenerator), "");

                foreach (XPathNavigator compoNav in xPathIterator)
                {
                    string name = compoNav.GetAttribute("Name", "");

                    try
                    {
                        // Create instance
                        MathGenerator newMathGen = (MathGenerator)ser.Deserialize(compoNav.SelectSingleNode("MathGenerator").ReadSubtree());

                        if (mMathGens.ContainsKey(name))
                        {
                            mMathGens[name] = newMathGen;
                        }
                        else
                        {
                            mMathGens.Add(name, newMathGen);
                        }
                    }
                    catch (Exception e)
                    {
                        //log.Add("Error loading MathGen " + name + " - " + e.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                //log.Add("Error loading MathGen Store - " + e.ToString());
            }
        }