You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
905 B
34 lines
905 B
using System;
|
|
using System.IO;
|
|
using System.Runtime.Serialization;
|
|
using System.Runtime.Serialization.Json;
|
|
using System.Xml;
|
|
using static System.Console;
|
|
using Model;
|
|
|
|
namespace Persistance
|
|
{
|
|
public class DataContractSerializer
|
|
{
|
|
public Theque DataContractSerializer()
|
|
{
|
|
Theque theque = new Theque();
|
|
|
|
Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory()));
|
|
string xmlFile = "theque.xml";
|
|
|
|
var serializer = new DataContractSerializer(typeof(Theque));
|
|
|
|
using (Stream s = File.Create(xmlFile))
|
|
{
|
|
serializer.WriteObject(s, theque);
|
|
}
|
|
|
|
Theque theque2;
|
|
using (Stream s = File.OpenRead(xmlFile))
|
|
{
|
|
theque2 = serializer.ReadObject(s) as Theque;
|
|
}
|
|
}
|
|
}
|
|
} |