コード例 #1
0
ファイル: Program.cs プロジェクト: cgt/Notes
		private static void SaveNotesHandler(object sender, FileChosenEventArgs e)
		{
			var xmlfmt = new XmlSerializer(typeof(Note[]));
			using (Stream fs = new FileStream(e.FileName, FileMode.Create, FileAccess.Write, FileShare.None))
			{
				var noteNodes = nodeStore.Cast<NoteNode>();
				xmlfmt.Serialize(fs, noteNodes.Select(n => n.Note).ToArray());
			}
		}
コード例 #2
0
ファイル: Program.cs プロジェクト: cgt/Notes
		private static void LoadNotesHandler(object sender, FileChosenEventArgs e)
		{
			var xmlfmt = new XmlSerializer(typeof(Note[]));
			using (Stream fs = new FileStream(e.FileName, FileMode.Open, FileAccess.Read, FileShare.None))
			{
				object notes =  xmlfmt.Deserialize(fs);

				foreach (Note n in (Note[])notes)
				{
					nodeStore.AddNode(new NoteNode(n));
				}
			}
		}