public static void Serialisationv1() { #region Initialisation Salaries listesal = new Salaries(); listesal.Add(new Salarie(new DateTime(1993, 11, 10), "12gty93", "CHESNE", "Sarah", 25000, 0.2)); listesal.Add(new Salarie(new DateTime(1998, 08, 27), "12gty98", "CHESNE", "Emilie", 23000, 0.2)); #endregion #region Exercice 2.1 CSV listesal.SaveText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv"); Salaries listesal2 = new Salaries(); listesal2.LoadText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv"); foreach (Salarie sal in listesal2) { Console.WriteLine(sal.ToString()); } #endregion #region XML listesal.SaveXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml"); Salaries listesal3 = new Salaries(); listesal3.LoadXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml"); foreach (Salarie sal2 in listesal3) { Console.WriteLine(sal2.ToString()); } #endregion #region Binaire listesal.SaveBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat"); Salaries listesal4 = new Salaries(); listesal4.LoadBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat"); foreach (Salarie sal3 in listesal4) { Console.WriteLine(sal3.ToString()); } #endregion }
static void TesterSalariesCVS() { Salaries ListeSalaries = new Salaries(); ListeSalaries.Add(new Salarie() { Matricule = "12XXX34", Nom = "Hemar", Prenom = "Mylene", DateNaissance = new DateTime(1988, 02, 20), SalaireBrut = 2000, TxCS = 0.20 }); ListeSalaries.Add(new Salarie("12XXX35", "Groot", "JeSAppelle", new DateTime(2000, 03, 19), 2500, 0.30)); ListeSalaries.SaveText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance"); ListeSalaries.LoadText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance"); foreach (Salarie item in ListeSalaries) { Console.WriteLine(item.ToString()); } Console.ReadLine(); }
private static void TestSaveLoadtxt(string dossier) { Console.WriteLine(salaries.SaveTxt(dossier)); salaries.Clear(); Console.WriteLine(salaries.LoadText(dossier)); }