예제 #1
0
        private void LoadGeneralConfig()
        {
            bool generateFile = true;

            if (File.Exists(generalConfigFile))
            {
                try
                {
                    generateFile = false;
                    TextReader    tr    = new StreamReader(generalConfigFile);
                    XmlSerializer xmSer = new XmlSerializer(typeof(CMSConfig));
                    generalConfig = (CMSConfig)xmSer.Deserialize(tr);
                    tr.Close();
                }
                catch (Exception e)
                {
                    generateFile = true;
                    try
                    {
                        File.Delete(generalConfigFile);
                    }
                    catch (Exception ee)
                    {
                    }
                }
            }

            if (generateFile)
            {
                generalConfig = new CMSConfig();
                generalConfig.SelectedSuiteName    = CMSConstants.STANDARD_TRACKING_SUITE_NAME;
                generalConfig.ControlTogglerConfig = new CMSControlTogglerConfig();

                try
                {
                    if (!Directory.Exists(Path.GetDirectoryName(generalConfigFile)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(generalConfigFile));
                    }
                    FileStream    fs    = new FileStream(generalConfigFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Delete | FileShare.ReadWrite);
                    TextWriter    tw    = new StreamWriter(fs);
                    XmlSerializer xmSer = new XmlSerializer(typeof(CMSConfig));
                    xmSer.Serialize(tw, generalConfig);
                    tw.Close();
                }
                catch (Exception e)
                {
                }
            }
        }
예제 #2
0
        public void LoadControlTogglerConfig()
        {
            CMSConfig newConfig = null;

            if (File.Exists(generalConfigFile))
            {
                TextReader    tr    = new StreamReader(CMSConstants.MAIN_CONFIG_FILE);
                XmlSerializer xmSer = new XmlSerializer(typeof(CMSConfig));
                newConfig = (CMSConfig)xmSer.Deserialize(tr);
                tr.Close();
            }
            else
            {
                newConfig = new CMSConfig();
            }

            generalConfig.ControlTogglerConfig.UpdateControlTogglerConfig(newConfig.ControlTogglerConfig);
        }