diff --git a/Sources/Model/Animal.cs b/Sources/Model/Animal.cs index 246b500..0e149ff 100644 --- a/Sources/Model/Animal.cs +++ b/Sources/Model/Animal.cs @@ -30,6 +30,7 @@ namespace Model } private string nom; + [DataMember(Name = "nomValid")] public bool NomIsValid { get => nomIsValid; @@ -126,7 +127,7 @@ namespace Model } private string alimentation; - [DataMember(Name = "espèce")] + [DataMember(Name = "espece")] public Espece? Espece { get => espece; diff --git a/Sources/Model/Entite.cs b/Sources/Model/Entite.cs index 747597e..483f259 100644 --- a/Sources/Model/Entite.cs +++ b/Sources/Model/Entite.cs @@ -1,105 +1,105 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations.Schema; -using System.IO.Pipes; -using System.Linq; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations.Schema; +using System.IO.Pipes; +using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - -namespace Model -{ - [DataContract(Name = "entite")] - public class Entite : INotifyPropertyChanged - { - public event PropertyChangedEventHandler? PropertyChanged; - - [DataMember(Name = "nom")] - public string Nom - { - get => nom; - set - { - if (nom == value) - return; - nom = value; - OnPropertyChanged(nameof(Nom)); - } - } - private string nom; - - [DataMember(Name = "adresse")] - public string Adresse - { - get => adresse; - set - { - if (adresse == value) - return; - adresse = value; - OnPropertyChanged(nameof(Adresse)); - } - } - private string adresse; - - [DataMember(Name = "codePostal")] - public int? CodePostal - { - get => codePostal; - set - { - if (codePostal == value) - return; - codePostal = value; - OnPropertyChanged(nameof(CodePostal)); - } - } - private int? codePostal; - - [DataMember(Name = "ville")] - public string Ville - { - get => ville; - set - { - if (ville == value) - return; - ville = value; - OnPropertyChanged(nameof(Ville)); - } - } - private string ville; - - [DataMember(Name = "numTel")] - public int? NumTel - { - get => numTel; - set - { - if(numTel == value) - return; - numTel = value; - OnPropertyChanged(nameof(NumTel)); - } - } - private int? numTel; - - public Entite(string nom = "", string adresse = "", int? codePostal = null, string ville = "", int? numTel = null) - { - Nom = nom; - Adresse = adresse; - CodePostal = codePostal; - Ville = ville; - NumTel = numTel; - } - - public void OnPropertyChanged(string propertyName) - { - if (PropertyChanged != null) - { - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + [DataContract(Name = "entite")] + public class Entite : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + + [DataMember(Name = "nom")] + public string Nom + { + get => nom; + set + { + if (nom == value) + return; + nom = value; + OnPropertyChanged(nameof(Nom)); + } + } + private string nom; + + [DataMember(Name = "adresse")] + public string Adresse + { + get => adresse; + set + { + if (adresse == value) + return; + adresse = value; + OnPropertyChanged(nameof(Adresse)); + } + } + private string adresse; + + [DataMember(Name = "codePostal")] + public int? CodePostal + { + get => codePostal; + set + { + if (codePostal == value) + return; + codePostal = value; + OnPropertyChanged(nameof(CodePostal)); + } + } + private int? codePostal; + + [DataMember(Name = "ville")] + public string Ville + { + get => ville; + set + { + if (ville == value) + return; + ville = value; + OnPropertyChanged(nameof(Ville)); + } + } + private string ville; + + [DataMember(Name = "numTel")] + public int? NumTel + { + get => numTel; + set + { + if(numTel == value) + return; + numTel = value; + OnPropertyChanged(nameof(NumTel)); + } + } + private int? numTel; + + public Entite(string nom = "", string adresse = "", int? codePostal = null, string ville = "", int? numTel = null) + { + Nom = nom; + Adresse = adresse; + CodePostal = codePostal; + Ville = ville; + NumTel = numTel; + } + + public void OnPropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} diff --git a/Sources/Persistance/DataSerializerBinary.cs b/Sources/Persistance/DataSerializerBinary.cs new file mode 100644 index 0000000..5310cfb --- /dev/null +++ b/Sources/Persistance/DataSerializerBinary.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Persistance +{ + internal class DataSerializerBinary + { + } +} diff --git a/Sources/Persistance/DataSerializer.cs b/Sources/Persistance/DataSerializerXML.cs similarity index 81% rename from Sources/Persistance/DataSerializer.cs rename to Sources/Persistance/DataSerializerXML.cs index 3e7195c..16f4493 100644 --- a/Sources/Persistance/DataSerializer.cs +++ b/Sources/Persistance/DataSerializerXML.cs @@ -1,52 +1,56 @@ -using System; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Json; -using System.Xml; -using static System.Console; -using Model; -using Microsoft.VisualBasic; -using System.Data; - -namespace Persistance -{ - public class DataSerializer - { - public static void Serializer(String path) - { - Theque theque = new Theque(); - - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path)); - string xmlFile = "theque.xml"; - - var serializer = new DataContractSerializer(typeof(Theque)); - - using (Stream s = File.Create(xmlFile)) - { - serializer.WriteObject(s, theque); - } - } - - public static Theque Deserializer(String path) - { - Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory())); - string xmlFile = "theque.xml"; - - var serializer = new DataContractSerializer(typeof(Theque)); - - Theque theque = new Theque(); - if(File.Exists(xmlFile)) - { - using (Stream s = File.OpenRead(xmlFile)) - { - theque = serializer.ReadObject(s) as Theque; - } - } - else - { - theque = Stub.LoadTheque(); - } - return theque; - } - } +using System; +using System.IO; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Json; +using System.Xml; +using static System.Console; +using Model; +using Microsoft.VisualBasic; +using System.Data; + +namespace Persistance +{ + public class DataSerializer + { + public static void Serializer(String path) + { + Theque theque = Stub.LoadTheque(); + + Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path)); + string xmlFile = "theque.xml"; + + var serializer = new DataContractSerializer(typeof(Theque)); + + using (Stream s = File.Create(xmlFile)) + { + serializer.WriteObject(s, theque); + } + } + + public static Theque Deserializer(String path) + { + Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory())); + string xmlFile = "theque.xml"; + + var serializer = new DataContractSerializer(typeof(Theque)); + + Theque theque = new Theque(); + if(File.Exists(xmlFile)) + { + using (Stream s = File.OpenRead(xmlFile)) + { + Theque? thequeOpt = serializer.ReadObject(s) as Theque; + if (thequeOpt != null) + theque = thequeOpt; + else + Console.WriteLine("Theque est null"); + } + } + else + { + theque = Stub.LoadTheque(); + } + return theque; + } + } } \ No newline at end of file diff --git a/Sources/Persistance/DateSerializerJson.cs b/Sources/Persistance/DateSerializerJson.cs new file mode 100644 index 0000000..9ae2172 --- /dev/null +++ b/Sources/Persistance/DateSerializerJson.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Persistance +{ + internal class DateSerializerJson + { + } +} diff --git a/Sources/Views/DetailAnimal.xaml b/Sources/Views/DetailAnimal.xaml index 2043c02..f4d0980 100644 --- a/Sources/Views/DetailAnimal.xaml +++ b/Sources/Views/DetailAnimal.xaml @@ -50,9 +50,10 @@ RowSpacing="8">