Ejemplo n.º 1
0
        public void LoadConfig()
        {
            tracer.PutEvent(TraceEventType.Information, 1, "ConfigManager.LoadConfig() has been started");
            Config result = new Config();
            try
            {
                using (FileStream fs = new FileStream(this.ConfigFile, FileMode.Open))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(Config));
                    result = xs.Deserialize(fs) as Config;
                }
            }
            catch (System.IO.IOException exception)
            {
                tracer.putError(354, String.Format("{0}, {1}", exception.Source, exception.Message));
            }

            configuration = result;
        }
Ejemplo n.º 2
0
        public void Init()
        {
            var applicationPath = Environment.CurrentDirectory;
            this.ConfigFile = Path.Combine(applicationPath, "pomodoro.config.xml");

            XmlSerializer xs = new XmlSerializer(typeof(Config));
            var config = new Config { DbFile = Path.Combine(applicationPath, "pomodoro.db"), Language = Thread.CurrentThread.CurrentUICulture.Name };

            StringWriter sw = new StringWriter();
            XmlWriter writer = XmlWriter.Create(sw);
            var xml = sw.ToString();

            try
            {
                using (FileStream fs = new FileStream(this.ConfigFile, FileMode.CreateNew))
                {
                    xs.Serialize(fs, config);
                }
            }
            catch (System.IO.IOException exception)
            {
                Console.WriteLine("{0}, {1}", exception.Source, exception.Message);
            }

            LoadConfig();
        }