public void Run() { int t0, t1; Log("GameLibCompiler started."); GameLib = new GameLibrary(); t0 = Environment.TickCount; GameLib.LoadJson(GAMELIB_JSON_PATH); t1 = Environment.TickCount; Log("Json load: " + (t1 - t0) + " ms."); // save using (var file = File.Create(GAMELIB_BIN_PATH)) { t0 = Environment.TickCount; Serializer.Serialize(file, GameLib.GetList().AsList()); t1 = Environment.TickCount; Log("Bin save: " + (t1 - t0) + " ms."); } // test load List<GardenItem> l; using (var file = File.OpenRead(GAMELIB_BIN_PATH)) { t0 = Environment.TickCount; l = Serializer.Deserialize<List<GardenItem>>(file); t1 = Environment.TickCount; Log("Bin load test 1: " + (t1 - t0) + " ms."); } // test load 2 t0 = Environment.TickCount; GameLibrary gl = new GameLibrary(); gl.LoadBin(GAMELIB_BIN_PATH); t1 = Environment.TickCount; Log("Bin load test 2: " + (t1 - t0) + " ms."); int c = gl.GetList().Count; }
protected bool LoadGameLibrary() { try { GameLib = new GameLibrary(); GameLib.LoadBin(Path.Combine(Content.RootDirectory, "gamelib.bin")); } catch (Exception ex) { IsMouseVisible = true; MsgBox.Show("Could not load game library file", "Could not load game library file. Technical:\n" + ex.Message + ";\n" + ex.StackTrace); initError = ex; return false; } return true; }