Exemplo n.º 1
0
        private void ProcessUnitList(XmlNode n, UnitMatrix um)
        {
            string  unitCode = "";
            decimal ep       = 0.0M;

            foreach (XmlNode unitNode in n.ChildNodes)
            {
                switch (unitNode.Name)
                {
                case "unitcode":
                    if (unitCode.Length > 0)
                    {
                        um.AddUnit(unitCode, ep);
                    }
                    unitCode = unitNode.InnerText;
                    break;

                case "ep":
                    ep = Decimal.Parse(unitNode.InnerText);
                    break;

                default:
                    break;
                }
            }
            um.AddUnit(unitCode, ep);
        }
Exemplo n.º 2
0
 private void AddTeam(string id, UnitMatrix um)
 {
     if (id.Length > 0)
     {
         matrixHT.Add(id, um);
     }
 }
Exemplo n.º 3
0
        public UnitMatrix GetMatrixFor(string teamCode)
        {
            UnitMatrix u = null;

            if (matrixHT == null)
            {
                LoadState();
            }
            if (matrixHT != null)
            {
                if (matrixHT.ContainsKey(teamCode))
                {
                    u = (UnitMatrix)matrixHT[teamCode];
                }
            }

            return(u);
        }
Exemplo n.º 4
0
        private void LoadState()
        {
            matrixHT = new Hashtable();
            UnitMatrix um = null;
            NflTeam    team;

            RosterLib.Utility.Announce("Loading saved Team EP");
            bool exists = File.Exists("teamEP.xml");

            if (exists)
            {
                epDoc = new XmlDocument();
                epDoc.Load("teamEP.xml");
                XmlNode root = epDoc.ChildNodes[2]; // skip node 1 as it is a comment
                foreach (XmlNode playerNode in root.ChildNodes)
                {
                    string teamCode = "";
                    foreach (XmlNode n in playerNode.ChildNodes)
                    {
                        switch (n.Name)
                        {
                        case "teamcode":
                            teamCode = n.InnerText;
                            break;

                        case "unit-list":
                            team = new NflTeam(teamCode);
                            um   = new UnitMatrix(team);
                            ProcessUnitList(n, um);
                            break;

                        default:
                            break;
                        }
                    }
                    if (um != null)
                    {
                        AddTeam(teamCode, um);
                    }
                }
                PrintIndexAndKeysAndValues(matrixHT);
            }
        }