Ejemplo n.º 1
0
 public static void TestXmlSerializing()
 {
     var answer = new Answer<string>("Ответ.", true);
     var xs = new XmlSerializer<Answer<string>>();
     using (var fileStream = File.Create(Path.Combine("save", "answer.xml")))
     {
         xs.Serialize(fileStream, answer);
     }
     using (var fileStream = File.OpenRead(Path.Combine("save", "answer.xml")))
     {
         var deserializedAnswer = xs.Deserialize(fileStream);
         Debug.Assert(deserializedAnswer.Contents == answer.Contents);
     }
 }
Ejemplo n.º 2
0
        public void Save(string projectFile, Globals.ProjectType projectType)
        {
            SerializableDictionary<string, object> dictPacked = new SerializableDictionary<string, object>();

            dictPacked.Add("_projectType", projectType);

            if (ProjectSaved != null) //something has been added to the list?
            {
                PackEventArgs e = new PackEventArgs(dictPacked);
                ProjectSaved(this, e);
            }

            FileInfo _fi = new FileInfo(projectFile);
            _projectName = _fi.Name;

            XmlSerializer serializerDict = new XmlSerializer();
            serializerDict.Serialize(dictPacked, projectFile);
        }