以下のクラスで次のエラーが発生します。
タイプ DataObjects.Ingredient のメンバー 'Ingredient' をシリアル化できません。XmlAttribute/XmlText を使用して複合型をエンコードすることはできません。
理由について何か考えはありますか?
[DataContract]
[Serializable]
[XmlRoot("ingredient")]
public class Ingredient
{
private string id;
private string name;
private string description;
private IngredientNutrient[] nutrients;
public Ingredient(string id, string name, string description, IngredientNutrient[] nutrients)
{
this.id = id;
this.name = name;
this.description = description;
this.nutrients = nutrients;
}
public Ingredient(string id, string name, string description)
{
this.id = id;
this.name = name;
this.description = description;
}
public Ingredient()
{
}
[DataMember]
[XmlAttribute("id")]
public string ID
{
get { return this.id; }
set { this.id = value; }
}
[DataMember]
[XmlAttribute("name")]
public string Name
{
get { return this.name; }
set { this.name = value; }
}
[DataMember]
[XmlAttribute("description")]
public string Description
{
get { return this.description; }
set { this.description = value; }
}
[DataMember]
[XmlArray("nutrients")]
[XmlArrayItem("ingredientnutrient")]
public IngredientNutrient[] Nutrients
{
get { return this.nutrients; }
set { this.nutrients = value; }
}
}