internal static void GenerateXmlfile() { Stopwatch stopwatch = Stopwatch.StartNew(); Console.WriteLine(); Console.Write(@"Generating Flags Xml file"); SerializableRoot <SerializableInvFlagsRow> flags = new SerializableRoot <SerializableInvFlagsRow> { Rowset = new SerialiazableRowset <SerializableInvFlagsRow> { Name = "flags", Key = "flagID", Columns = "flagID,flagName,flagText" } }; flags.Rowset.Rows.AddRange(Database.InvFlagsTable.Select( flag => new SerializableInvFlagsRow { ID = flag.ID, Name = flag.Name, Text = flag.Text })); Util.DisplayEndTime(stopwatch); Console.WriteLine(); // Serialize Util.SerializeXmlTo(flags, "invFlags", "Flags.xml"); }
internal static void GenerateXmlfile() { Stopwatch stopwatch = Stopwatch.StartNew(); Console.WriteLine(); Console.Write(@"Generating Flags Xml file"); SerializableRoot<SerializableInvFlagsRow> flags = new SerializableRoot<SerializableInvFlagsRow> { Rowset = new SerialiazableRowset<SerializableInvFlagsRow> { Name = "flags", Key = "flagID", Columns = "flagID,flagName,flagText" } }; flags.Rowset.Rows.AddRange(Database.InvFlagsTable.Select( flag => new SerializableInvFlagsRow { ID = flag.ID, Name = flag.Name, Text = flag.Text })); Util.DisplayEndTime(stopwatch); Console.WriteLine(); // Serialize Util.SerializeXmlTo(flags, "invFlags", "Flags.xml"); }
public void SerializeRoot(string fileName, SerializableRoot objToSerialize) { FileStream fstream = File.Open(fileName, FileMode.Create); BinaryFormatter binform = new BinaryFormatter(); binform.Serialize(fstream, objToSerialize); fstream.Close(); }
public SerializableRoot DeserializeRoot(string fileName) { SerializableRoot objToSerialize = null; FileStream fstream = File.Open(fileName, FileMode.Open); BinaryFormatter binform = new BinaryFormatter(); objToSerialize = (SerializableRoot)binform.Deserialize(fstream); fstream.Close(); return(objToSerialize); }