Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- namespace activite
- {
- [Serializable()]
- public class Agenda
- {
- [NonSerialized]private String name;
- private List<Activite> listeActivite;
- public Agenda()
- {
- setAgenda("Inconnu", null);
- }
- public Agenda(String n)
- {
- nom = n;
- listAct = new List<Activite>();
- }
- //public Agenda(String n, List<Activite> l)
- //{
- // setAgenda(n, l);
- //}
- private void setAgenda(String n , List<Activite> l)
- {
- nom = n;
- listAct = l;
- }
- //propriétés
- public String nom
- {
- set { name = value; }
- get { return name; }
- }
- public List<Activite> listAct
- {
- set { listeActivite = value; }
- get { return listeActivite; }
- }
- /*public void load()
- {
- string path = @"C:\agenda\agendas\" + nom + ".age";
- load(path);
- }*/
- public void load(string filePath)
- {
- Stream stream = File.Open(filePath, FileMode.Open);
- BinaryFormatter formater = new BinaryFormatter();
- Agenda obj = (Agenda)formater.Deserialize(stream);
- this.listAct = obj.listAct;
- stream.Close();
- }
- /*public void save()
- {
- string path = @"C:\agenda\agendas\" + nom + ".age";
- save(path);
- }*/
- public void save(string filePath)
- {
- Stream stream = File.Open(filePath, FileMode.Create);
- BinaryFormatter formater = new BinaryFormatter();
- formater.Serialize(stream,this);
- stream.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment