Esempio n. 1
0
 public static void Serialize(string file, Configuration c)
 {
     System.Xml.Serialization.XmlSerializer xs
         = new System.Xml.Serialization.XmlSerializer(c.GetType());
      	StreamWriter writer = File.CreateText(file);
      	xs.Serialize(writer, c);
      	writer.Flush();
      	writer.Close();
 }
Esempio n. 2
0
        private dbConnector()
        {
            System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly();
            string baseDir = System.IO.Path.GetDirectoryName(a.Location);
            conf = Configuration.Deserialize(baseDir+"/config.xml");

            string connectionString = string.Format(@"Server={0}; Database={1}; User ID={2}; Password={3};
                                    charset=utf8; Pooling=false",conf.server,conf.db,conf.user,conf.password);

            try
            {
              			dbcon = new MySqlConnection(connectionString);
               			dbcon.Open();
            }
            catch
            {
                Utils.showMessageError("что-то пошло не так(");
            }
        }