Example #1
0
        public void SaveBrdData()
        {
            BoardXmlInfo brdXml = new BoardXmlInfo();

            foreach (KeyValuePair <string, BoardInfo> pair in dicBrd)
            {
                BoardInfoEx infoEx = new BoardInfoEx();
                infoEx.kind    = pair.Key;
                infoEx.kindNum = pair.Value.kindNum;

                foreach (KeyValuePair <string, BoardInfoDetail> pairD in pair.Value.dicText)
                {
                    infoEx.lstBrdInof.Add(pairD.Value);
                }

                brdXml.lstXml.Add(infoEx);
            }

            using (Stream stream = new FileStream(Util.file_BrdData, FileMode.Create))
            {
                XmlSerializer ser = new XmlSerializer(typeof(BoardXmlInfo));
                ser.Serialize(stream, brdXml);
                stream.Close();
            }
        }
Example #2
0
        public bool LoadBrdData()
        {
            dicBrd.Clear();

            if (!File.Exists(Util.file_BrdData))
            {
                return(false);
            }

            BoardXmlInfo brdXml = new BoardXmlInfo();

            using (Stream stream = new FileStream(Util.file_BrdData, FileMode.Open))
            {
                XmlSerializer ser = new XmlSerializer(typeof(BoardXmlInfo));
                brdXml = (BoardXmlInfo)ser.Deserialize(stream);
            }

            foreach (BoardInfoEx brd in brdXml.lstXml)
            {
                BoardInfo info = new BoardInfo();
                info.kind    = brd.kind;
                info.kindNum = brd.kindNum;

                foreach (BoardInfoDetail brdt in brd.lstBrdInof)
                {
                    info.dicText.Add(brdt.name, brdt);
                }

                dicBrd.Add(info.kind, info);
            }

            return(true);
        }