public static BasicNetwork loadNetwork() { MongoServer server = new MongoServer (MongoServerSettings.FromUrl (new MongoUrl ("mongodb://Dev-Svr2.systest.sc2services.com"))); var fs = new MongoDB.Driver.GridFS.MongoGridFS (server.GetDatabase ("Results")); var file = fs.OpenRead ("tttnetwork.net"); var lf = System.IO.File.OpenWrite ("tttnetwork.net"); var l = file.Length; for (int x = 0; x < l; x++) { lf.WriteByte (Convert.ToByte (file.ReadByte ())); } lf.Close (); file.Close (); var network = SerializeObject.Load ("tttnetwork.net"); System.IO.File.Delete ("tttnetwork.net"); return (BasicNetwork)network; }
public static void SaveNetwork(BasicNetwork net) { MongoServer server = new MongoServer (MongoServerSettings.FromUrl (new MongoUrl ("mongodb://Dev-Svr2.systest.sc2services.com"))); var fs = new MongoDB.Driver.GridFS.MongoGridFS (server.GetDatabase ("Results")); var file = fs.Open ("tttnetwork.net", FileMode.OpenOrCreate); SerializeObject.Save ("tttnetwork.net", net); var lf = System.IO.File.OpenRead ("tttnetwork.net"); var l = lf.Length; for (int x = 0; x < l; x++) { file.WriteByte (Convert.ToByte (lf.ReadByte ())); } lf.Close (); file.Close (); System.IO.File.Delete ("tttnetwork.net"); }