I have been working on a kitchen app and it needs to save recipes. Everything works fine with the XML Serialization except List<IngredientMeasure> IngredientList
. I have heard a lot of other people have had problems serializing lists of classes too, and I saw this: Serializing Lists of Classes to XML.
I tried the solutions there, but none of them worked.
Here are the fields for the Recipe
class:
[DataContract]
public class Recipe
{
[DataMember]
public static List<Recipe> RecipeList = new List<Recipe>();
[DataMember]
public string Name { get; set; }
[DataMember]
public string FilePath { get; set; }
[DataMember]
public List<IngredientMeasure> IngredientList { get; set; }
[XmlArray("IngredientsList")]
public List<string> Ingredients = new List<string>();
[DataMember]
public List<string> DirectionList { get; private set; }
[DataMember]
public List<string> Notes { get; private set; }
public Recipe()
{
}
}
Here is the IngredientMeasure
class:
public class IngredientMeasure
{
[DataMember]
public Ingredient ingredient;
[DataMember]
public Measure measure;
public IngredientMeasure()
{
}
}
Any help is appreciated.