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

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.