void IXleSerializable.ReadData(XleSerializationInfo info) { Cheater = info.ReadBoolean("Cheater", false); mAttributes = (AttributeContainer)info.ReadObject("Attributes"); food = info.ReadDouble("Food"); gold = info.ReadInt32("Gold"); goldBank = info.ReadInt32("GoldInBank"); timedays = info.ReadDouble("TimeDays"); timequality = info.ReadDouble("TimeQuality"); onRaft = info.ReadInt32("OnRaft"); rafts = info.ReadList <RaftData>("Rafts"); gamespeed = info.ReadInt32("GameSpeed"); map = info.ReadInt32("Map"); lastMap = info.ReadInt32("LastMap"); dungeon = info.ReadInt32("Dungeon"); hp = info.ReadInt32("HP"); level = info.ReadInt32("Level"); returnMap = info.ReadInt32("ReturnMap"); returnX = info.ReadInt32("ReturnX"); returnY = info.ReadInt32("ReturnY"); returnFacing = info.ReadEnum <Direction>("ReturnFacing"); x = info.ReadInt32("X"); y = info.ReadInt32("Y"); dungeonLevel = info.ReadInt32("DungeonLevel"); faceDirection = (Direction)info.ReadInt32("Facing"); weapons = info.ReadList <WeaponItem>("Weapons"); armor = info.ReadList <ArmorItem>("Armor"); currentArmorIndex = info.ReadInt32("CurrentArmorIndex"); currentWeaponIndex = info.ReadInt32("CurrentWeaponIndex"); mItems = info.ReadObject <ItemContainer>("Item"); hold = info.ReadInt32("Hold"); lastAttacked = info.ReadInt32("LastAttacked"); VaultGold = info.ReadInt32("VaultGold"); chests = info.ReadArray <int>("Chests"); loan = info.ReadInt32("Loan"); // loan amount dueDate = info.ReadInt32("DueDate"); // time in days that the money is due mailTown = info.ReadInt32("MailTown"); mName = info.ReadString("Name"); StoryData = info.ReadObject <IXleSerializable>("StoryData"); RenderColor = XleColor.White; }
/// <summary> /// Writes an object implementing IXleSerializable to the XML data as an element. /// </summary> /// <param name="name">The name of the XML element used.</param> /// <param name="value">The object data to write.</param> public void Write(string name, IXleSerializable value) { XmlElement element = CreateElement(name); AddAttribute(element, "type", value.GetType().ToString()); nodes.Push(element); Serialize(value); nodes.Pop(); }
/// <summary> /// Serializes an object which implements IXleSerializable to the specified stream. /// </summary> /// <param name="outStream">The stream to write the XML data to.</param> /// <param name="objectGraph">The object to serialize.</param> public void Serialize(Stream outStream, IXleSerializable objectGraph) { if (objectType.GetTypeInfo().IsAssignableFrom(objectGraph.GetType().GetTypeInfo()) == false) { throw new ArgumentException("Object is not of type " + objectType.Name); } XleSerializationInfo info = new XleSerializationInfo(Binder, TypeSerializers); info.BeginSerialize(objectGraph); info.XmlDoc.Save(outStream); }
internal void BeginSerialize(IXleSerializable objectGraph) { var root = doc.CreateElement("XleRoot"); AddAttribute(root, "type", objectGraph.GetType().ToString()); doc.AppendChild(root); nodes.Push(root); Serialize(objectGraph); System.Diagnostics.Debug.Assert(nodes.Count == 1); nodes.Clear(); }
void Serialize(IXleSerializable o) { o.WriteData(this); }