2017-02-01 16:06:52 +02:00
|
|
|
|
using System;
|
2017-02-01 17:35:17 +02:00
|
|
|
|
using System.Collections.Generic;
|
2017-02-01 18:08:40 +02:00
|
|
|
|
using System.Linq;
|
2017-02-01 17:21:58 +02:00
|
|
|
|
using System.Xml.Linq;
|
2017-02-01 17:35:17 +02:00
|
|
|
|
using System.Xml.Serialization;
|
2017-02-01 16:06:52 +02:00
|
|
|
|
|
|
|
|
|
namespace vr21
|
|
|
|
|
{
|
2017-02-01 17:35:17 +02:00
|
|
|
|
public class Receipe
|
|
|
|
|
{
|
|
|
|
|
public string Name;
|
2017-02-01 18:08:40 +02:00
|
|
|
|
public string Description;
|
2017-02-01 17:35:17 +02:00
|
|
|
|
public List<Ingredient> Ingredients;
|
2017-02-01 18:08:40 +02:00
|
|
|
|
public List<string> Steps;
|
2017-02-01 17:35:17 +02:00
|
|
|
|
|
|
|
|
|
public Receipe()
|
|
|
|
|
{
|
|
|
|
|
Ingredients = new List<Ingredient>();
|
2017-02-01 18:08:40 +02:00
|
|
|
|
Steps = new List<string>();
|
2017-02-01 17:35:17 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Ingredient
|
|
|
|
|
{
|
|
|
|
|
public string Name;
|
|
|
|
|
public int Count;
|
|
|
|
|
public string Unit;
|
|
|
|
|
}
|
2017-02-01 16:06:52 +02:00
|
|
|
|
class Program
|
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
private static string _xmllocation = @"..\..\..\XMLRecipe.xml";
|
2017-02-01 16:06:52 +02:00
|
|
|
|
static void Main(string[] args)
|
2017-02-01 17:35:17 +02:00
|
|
|
|
{
|
|
|
|
|
Ingredient kartul = new Ingredient() {Name = "Kartul", Count = 500, Unit = "g"};
|
|
|
|
|
Receipe r = new Receipe() {Name="Supp"};
|
|
|
|
|
r.Ingredients.Add(kartul);
|
|
|
|
|
r.Ingredients.Add(kartul);
|
2017-02-01 18:08:40 +02:00
|
|
|
|
r.Steps.Add("Koori");
|
|
|
|
|
r.Steps.Add("Keeda");
|
2017-02-01 17:35:17 +02:00
|
|
|
|
List<Receipe> l = new List<Receipe>();
|
|
|
|
|
l.Add(r);
|
|
|
|
|
l.Add(r);
|
|
|
|
|
XmlSerializer x = new XmlSerializer(l.GetType());
|
2017-02-01 18:08:40 +02:00
|
|
|
|
// x.Serialize(Console.Out, l);
|
2017-02-01 17:35:17 +02:00
|
|
|
|
//writeReceipesInformation();
|
2017-02-01 18:08:40 +02:00
|
|
|
|
|
|
|
|
|
LineEditor le = new LineEditor("foo") {HeuristicsMode = "csharp"};
|
|
|
|
|
string s;
|
|
|
|
|
|
|
|
|
|
while ((s = le.Edit("shell> ", "")) != null)
|
|
|
|
|
{
|
|
|
|
|
var arguments = s.Split(' ');
|
|
|
|
|
var command = arguments[0].Trim();
|
|
|
|
|
switch (command.ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "list":
|
|
|
|
|
Console.WriteLine("Tere");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Console.WriteLine("No command");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-01 17:21:58 +02:00
|
|
|
|
}
|
2017-02-01 17:03:44 +02:00
|
|
|
|
|
2017-02-01 17:21:58 +02:00
|
|
|
|
static void writeReceipesInformation()
|
|
|
|
|
{
|
|
|
|
|
XDocument xdoc = XDocument.Load(_xmllocation);
|
|
|
|
|
var allReceipes = xdoc.Descendants("Recipe");
|
|
|
|
|
foreach (var receipe in allReceipes)
|
2017-02-01 17:03:44 +02:00
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
Console.WriteLine(receipe.Element("Name").Value);
|
|
|
|
|
foreach (var ingredient in receipe.Element("Ingredients").Elements())
|
2017-02-01 17:03:44 +02:00
|
|
|
|
{
|
2017-02-01 17:21:58 +02:00
|
|
|
|
Console.WriteLine($" {ingredient.Element("Name").Value}: {ingredient.Element("Amount").Value}{ingredient.Element("Unit").Value}");
|
2017-02-01 17:03:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-01 16:06:52 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|