This commit is contained in:
Arti Zirk 2017-02-01 17:03:44 +02:00
parent 03bf898def
commit 06fdcc6d79
8 changed files with 3159 additions and 0 deletions

28
XMLRecipe.xml Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Recipes>
<Recipe>
<Name>Supp</Name>
<Description>
Väga hea supp
</Description>
<Ingredients>
<Ingredient>
<Name>Porgand</Name>
<Amount multiplierPerPortion="2">100</Amount>
<Unit>g</Unit>
</Ingredient>
<Ingredient>
<Name>Kartul</Name>
<Amount multiplierPerPortion="2">200</Amount>
<Unit>g</Unit>
</Ingredient>
</Ingredients>
<Steps>
<Step>Koori kartul</Step>
<Step>Pese porgand</Step>
<Step>Kõik potti keema</Step>
<Step>Oota kuni valmis</Step>
<Step>Serveeri ja naudi</Step>
</Steps>
</Recipe>
</Recipes>

View File

@ -5,6 +5,11 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vr21", "vr21\vr21.csproj", "{671423E9-E7F4-420B-986E-D412F351DBC9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D77C97-38A2-4C5F-96F4-ABC994D9CDD6}"
ProjectSection(SolutionItems) = preProject
XMLRecipe.xml = XMLRecipe.xml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

View File

@ -1,15 +1,99 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.SqlServer.Server;
namespace vr21
{
[XmlRoot("Recipes")]
public class Recipes
{
[XmlElement("Recipe")]
public List<Recipe> RecipeList { get; set; }
public Recipes()
{
RecipeList = new List<Recipe>();
}
}
public class Recipe
{
[XmlElement("Name")]
public string Name { get; set; }
[XmlElement("Ingredient")]
public List<Ingredient> IngredientsList { get; set; }
[XmlElement("Step")]
public List<string> StepList { get; set; }
public Recipe()
{
IngredientsList = new List<Ingredient>();
StepList = new List<string>();
}
public Recipe(string name)
{
Name = name;
IngredientsList = new List<Ingredient>();
StepList = new List<string>();
}
public Recipe(string name, List<Ingredient> ingredients)
{
Name = name;
IngredientsList = ingredients;
StepList = new List<string>();
}
}
public class Ingredient
{
[XmlElement("Name")]
public string Name { get; set; }
[XmlElement("Amount")]
public int Amount { get; set; }
public Ingredient(string name)
{
Name = name;
Amount = 1;
}
public Ingredient(string name, int amount)
{
Name = name;
Amount = amount;
}
}
class Program
{
static void Main(string[] args)
{
var recipes = new Recipes();
recipes.RecipeList.Add(new Recipe("Supp"));
XmlSerializer serializer = new XmlSerializer(typeof(Recipes));
var xml = "";
using (var sww = new StringWriter())
{
using (XmlWriter writer = XmlWriter.Create(sww))
{
serializer.Serialize(writer, recipes);
xml = sww.ToString(); // Your XML
}
}
Console.WriteLine(xml);
}
}
}

2970
vr21/XMLRecipe.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

1
vr21/XMLRecipe.xsc Normal file
View File

@ -0,0 +1 @@


54
vr21/XMLRecipe.xsd Normal file
View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Recipes" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Recipes" msdata:IsDataSet="true" msdata:Locale="en-US">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Recipe">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="Ingredients" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="Unit" type="xs:string" minOccurs="0" />
<xs:element name="Amount" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent msdata:ColumnName="Amount_Text" msdata:Ordinal="1">
<xs:extension base="xs:string">
<xs:attribute name="multiplierPerPortion" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Steps" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Step" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent msdata:ColumnName="Step_Text" msdata:Ordinal="0">
<xs:extension base="xs:string">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

1
vr21/XMLRecipe.xss Normal file
View File

@ -0,0 +1 @@


View File

@ -45,9 +45,25 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XMLRecipe.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>XMLRecipe.xsd</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="XMLRecipe.xsc">
<DependentUpon>XMLRecipe.xsd</DependentUpon>
</None>
<None Include="XMLRecipe.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>XMLRecipe.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</None>
<None Include="XMLRecipe.xss">
<DependentUpon>XMLRecipe.xsd</DependentUpon>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.