This class provides the basic functionality for persisting a user's progress through the game, as well as their option preferences. It uses the .NET Framework's XML serialization facility, provided by System.Xml.Serialization and the XmlSerializer class. Any future persisted data should follow the approach here.
Example of loading a UserProfile:
XmlSerializer serializer = new XmlSerializer(typeof(UserProfile));
UserProfile profile = null;
using (XmlReader reader = new XmlTextReader("Content/profile.xml")) {
profile = (UserProfile)serializer.Deserialize(reader);
}
Saving a UserProfile:
using (XmlWriter writer = new XmlTextWriter("Content/profile.xml", System.Text.Encoding.UTF8)) {
serializer.Serialize(writer, profile);
}
This class provides the basic functionality for persisting a user's progress through the game, as well as their option preferences. It uses the .NET Framework's XML serialization facility, provided by System.Xml.Serialization and the XmlSerializer class. Any future persisted data should follow the approach here.
Example of loading a UserProfile:
Saving a UserProfile: