Avancement dans persistance, Serialization Espece dans theque

pull/18/head
Leana BESSON 2 years ago
parent ae2fa75b01
commit 9880b8e510

@ -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;

@ -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));
}
}
}
}

@ -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
{
}
}

@ -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;
}
}
}

@ -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
{
}
}

@ -50,9 +50,10 @@
RowSpacing="8">
<Label FontAttributes="Bold"
Text="Date de naissance"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding DateNaissance}"/>
<DatePicker Grid.Column="1"
MinimumDate="01/01/2000"
HorizontalOptions="End"
Date="{Binding DateNaissance}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Sexe"/>
@ -63,10 +64,11 @@
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Date d'adoption"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding DateAdoption}"/>
<DatePicker Grid.Column="1"
Grid.Row="2"
MinimumDate="01/01/2000"
HorizontalOptions="End"
Date="{Binding DateAdoption}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Taille"/>
@ -144,35 +146,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Nom}"/>
Text="{Binding Petsitter.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Adresse}"/>
Text="{Binding Petsitter.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.CodePostal}"/>
Text="{Binding Petsitter.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Ville}"/>
Text="{Binding Petsitter.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.NumTel}"/>
Text="{Binding Petsitter.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -191,35 +193,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Nom}"/>
Text="{Binding Chenil.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Adresse}"/>
Text="{Binding Chenil.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.CodePostal}"/>
Text="{Binding Chenil.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Ville}"/>
Text="{Binding Chenil.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.NumTel}"/>
Text="{Binding Chenil.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -238,7 +240,7 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Nom}"/>
Text="{Binding Veterinaire.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Clinique"/>
@ -252,28 +254,28 @@
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Adresse}"/>
Text="{Binding Veterinaire.Adresse}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.CodePostal}"/>
Text="{Binding Veterinaire.CodePostal}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Ville}"/>
Text="{Binding Veterinaire.Ville}"/>
<Label Grid.Row="5"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="5"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.NumTel}"/>
Text="{Binding Veterinaire.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -292,35 +294,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Nom}"/>
Text="{Binding MagasinAlimentaire.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Adresse}"/>
Text="{Binding MagasinAlimentaire.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.CodePostal}"/>
Text="{Binding MagasinAlimentaire.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Ville}"/>
Text="{Binding MagasinAlimentaire.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.NumTel}"/>
Text="{Binding MagasinAlimentaire.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -339,35 +341,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Nom}"/>
Text="{Binding Provenance.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Adresse}"/>
Text="{Binding Provenance.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.CodePostal}"/>
Text="{Binding Provenance.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Ville}"/>
Text="{Binding Provenance.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.NumTel}"/>
Text="{Binding Provenance.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>

@ -150,35 +150,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Nom}"/>
Text="{Binding Petsitter.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Adresse}"/>
Text="{Binding Petsitter.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.CodePostal}"/>
Text="{Binding Petsitter.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.Ville}"/>
Text="{Binding Petsitter.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Petsitter.Entite.NumTel}"/>
Text="{Binding Petsitter.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -197,35 +197,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Nom}"/>
Text="{Binding Chenil.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Adresse}"/>
Text="{Binding Chenil.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.CodePostal}"/>
Text="{Binding Chenil.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.Ville}"/>
Text="{Binding Chenil.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Chenil.Entite.NumTel}"/>
Text="{Binding Chenil.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -244,7 +244,7 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Nom}"/>
Text="{Binding Veterinaire.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Clinique"/>
@ -258,28 +258,28 @@
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Adresse}"/>
Text="{Binding Veterinaire.Adresse}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.CodePostal}"/>
Text="{Binding Veterinaire.CodePostal}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.Ville}"/>
Text="{Binding Veterinaire.Ville}"/>
<Label Grid.Row="5"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="5"
HorizontalOptions="End"
Text="{Binding Veterinaire.Entite.NumTel}"/>
Text="{Binding Veterinaire.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -298,35 +298,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Nom}"/>
Text="{Binding MagasinAlimentaire.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Adresse}"/>
Text="{Binding MagasinAlimentaire.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.CodePostal}"/>
Text="{Binding MagasinAlimentaire.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.Ville}"/>
Text="{Binding MagasinAlimentaire.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding MagasinAlimentaire.Entite.NumTel}"/>
Text="{Binding MagasinAlimentaire.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>
@ -345,35 +345,35 @@
Text="Nom"/>
<Entry Grid.Column="1"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Nom}"/>
Text="{Binding Provenance.Nom}"/>
<Label Grid.Row="1"
FontAttributes="Bold"
Text="Adresse"/>
<Entry Grid.Column="1"
Grid.Row="1"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Adresse}"/>
Text="{Binding Provenance.Adresse}"/>
<Label Grid.Row="2"
FontAttributes="Bold"
Text="Code postal"/>
<Entry Grid.Column="1"
Grid.Row="2"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.CodePostal}"/>
Text="{Binding Provenance.CodePostal}"/>
<Label Grid.Row="3"
FontAttributes="Bold"
Text="Ville"/>
<Entry Grid.Column="1"
Grid.Row="3"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.Ville}"/>
Text="{Binding Provenance.Ville}"/>
<Label Grid.Row="4"
FontAttributes="Bold"
Text="Numéro de téléphone"/>
<Entry Grid.Column="1"
Grid.Row="4"
HorizontalOptions="End"
Text="{Binding Provenance.Entite.NumTel}"/>
Text="{Binding Provenance.NumTel}"/>
</Grid>
</Border>
</VerticalStackLayout>

Loading…
Cancel
Save