我有一个 IList 类,但是当我尝试将它们存储在 IsolatedStorage 中时,它只是说内置的序列化程序无法处理它,JSON.net 也不能。我已经把这个类放在下面了,有人能想出一种存储它的方法吗?
我得到的错误是;
无法序列化类型“System.Windows.UIElement”。考虑使用 DataContractAttribute 属性对其进行标记,并使用 DataMemberAttribute 属性标记您想要序列化的所有成员。
IList<ScoreWatcher> RecentSessions = new List<ScoreWatcher>();
public class ScoreWatcher
{
public ScoreWatcher() { }
public string SessionName = "";
public DateTime SessionCreationTime;
public DateTime SessionModificationTime;
public int Player1Total = 0;
public int Player1ScoreRollover = 0;
public int Player2Total = 0;
public int Player2ScoreRollover = 0;
public string Player1Name = "";
public string Player2Name = "";
public ListBox scoreListBox;
public string GrabFriendlyGLobal()
{
UpdateModificationTime();
return string.Format("{0}-{1}", Player1Total, Player2Total);
}
public void UpdateModificationTime()
{
SessionModificationTime = DateTime.Now;
}
public void UpdateScoringSystem()
{
UpdateModificationTime();
Player1Total = 0;
Player1ScoreRollover = 0;
Player2Total = 0;
Player2ScoreRollover = 0;
foreach (Match snookerMatch in matches)
{
if (snookerMatch.Player1Score > snookerMatch.Player2Score)
Player1Total++;
else if (snookerMatch.Player1Score == snookerMatch.Player2Score)
{
Player1Total++;
Player2Total++;
}
else
Player2Total++;
// House cleaning
Player1ScoreRollover += snookerMatch.Player1Score;
Player2ScoreRollover += snookerMatch.Player2Score;
}
}
public void LoadMatchesIntoListbox()
{
UpdateModificationTime();
scoreListBox.Items.Clear();
foreach (Match snookerMatch in matches)
scoreListBox.Items.Add(new UserControls.GameHistoryTile(snookerMatch.GlobalScore, snookerMatch.Player1Score, snookerMatch.Player2Score));
}
public List<Match> matches = new List<Match>();
public class Match
{
public int Player1Score = 0;
public int Player2Score = 0;
public string GlobalScore = "0-0";
}
}