From e3a3880d6229a4d4ecc915559b26d0648112bbe7 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Wed, 1 Feb 2017 17:35:17 +0200 Subject: [PATCH] Serialize test --- vr21/Program.cs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/vr21/Program.cs b/vr21/Program.cs index c88679c..fad34a7 100644 --- a/vr21/Program.cs +++ b/vr21/Program.cs @@ -1,14 +1,42 @@ using System; +using System.Collections.Generic; using System.Xml.Linq; +using System.Xml.Serialization; namespace vr21 { + public class Receipe + { + public string Name; + public List Ingredients; + + public Receipe() + { + Ingredients = new List(); + } + } + + public class Ingredient + { + public string Name; + public int Count; + public string Unit; + } class Program { private static string _xmllocation = @"..\..\..\XMLRecipe.xml"; static void Main(string[] args) - { - writeReceipesInformation(); + { + Ingredient kartul = new Ingredient() {Name = "Kartul", Count = 500, Unit = "g"}; + Receipe r = new Receipe() {Name="Supp"}; + r.Ingredients.Add(kartul); + r.Ingredients.Add(kartul); + List l = new List(); + l.Add(r); + l.Add(r); + XmlSerializer x = new XmlSerializer(l.GetType()); + x.Serialize(Console.Out, l); + //writeReceipesInformation(); Console.ReadKey(); }