예제 #1
0
        public void fXML_Writer(string strXMLPath, Dictionary <string, string> DXMLConfig)
        {
            StringBuilder sb = new StringBuilder();

            //using (XmlWriter wr = XmlWriter.Create(strXMLPath))
            using (XmlWriter wr = XmlWriter.Create(sb))
            {
                wr.WriteStartDocument();

                //SETTING
                wr.WriteStartElement("SETTING");
                wr.WriteAttributeString("ID", "0001");

                wr.WriteElementString(_TICK, DXMLConfig[_TICK]);
                wr.WriteElementString(_TOTAL, DXMLConfig[_TOTAL]);
                wr.WriteElementString(_LEVEL_1, DXMLConfig[_LEVEL_1]);
                wr.WriteElementString(_LEVEL_3, DXMLConfig[_LEVEL_3]);
                wr.WriteElementString(_LEVEL_50, DXMLConfig[_LEVEL_50]);

                wr.WriteEndElement();
                wr.WriteEndDocument();
            }
            string strRijndaelTet = CRijndael.EncryptString(sb.ToString(), CRijndael._bKey);

            File.WriteAllText(strXMLPath, strRijndaelTet);
        }
예제 #2
0
        public Dictionary <string, string> fXML_Reader(string strXMLPath)
        {
            string strRijndaelText = File.ReadAllText(strXMLPath);
            string strDECText      = CRijndael.DecryptString(strRijndaelText, CRijndael._bKey);


            Dictionary <string, string> DXMLConfig = new Dictionary <string, string>();

            using (XmlReader rd = XmlReader.Create(new StringReader(strDECText)))
            {
                while (rd.IsStartElement())
                {
                    if (rd.Name.Equals("SETTING"))
                    {
                        string strId = rd["ID"];
                        rd.Read();
                        string strTICK = rd.ReadElementContentAsString(_TICK, "");
                        DXMLConfig.Add(_TICK, strTICK);

                        string strTOTAL = rd.ReadElementContentAsString(_TOTAL, "");
                        DXMLConfig.Add(_TOTAL, strTOTAL);

                        string strLEVEL_1 = rd.ReadElementContentAsString(_LEVEL_1, "");
                        DXMLConfig.Add(_LEVEL_1, strLEVEL_1);

                        string strLEVEL_3 = rd.ReadElementContentAsString(_LEVEL_3, "");
                        DXMLConfig.Add(_LEVEL_3, strLEVEL_3);

                        string strLEVEL_50 = rd.ReadElementContentAsString(_LEVEL_50, "");
                        DXMLConfig.Add(_LEVEL_50, strLEVEL_50);
                    }
                }
            }

            return(DXMLConfig);
        }