Ejemplo n.º 1
0
 public System.Object Load(Version fv, WsgFileStream fs, System.Object obj)
 {
     try
     {
         if (BeforeLoadEvent != null)
         {
             BeforeLoadEvent();
         }
         if (fv.Major > 0)
         {
             while (PlayTimer.Enabled)
             {
                 PlayTimer.Stop();
             }
             fs.Seek(0, System.IO.SeekOrigin.Begin);
             Version loadedfv = (Version)FileVersion.Load(fv, fs, null);
             while (StockIndexes.Count > 0)
             {
                 StockIndexes.Clear();
             }
             while (Stocks.Count > 0)
             {
                 Stocks.Clear();
             }
             while (Players.Count > 0)
             {
                 Players.Clear();
             }
             MarketState.Reset(Random);
             CurrentPlayer = null;
             StockIndexes.Load(loadedfv, fs, null);
             Stocks.Load(loadedfv, fs, StockIndexes);
             CurrentPlayer = (Player)Players.Load(loadedfv, fs, Stocks);
             MarketState.Load(loadedfv, fs, null);
             FileName = fs.Name;
             while (!PlayTimer.Enabled)
             {
                 PlayTimer.Start();
             }
         }
         if (AfterLoadEvent != null)
         {
             AfterLoadEvent();
         }
         if (UpdateStockInformationsEvent != null)
         {
             UpdateStockInformationsEvent();
         }
         if (UpdatePlayerInformationsEvent != null)
         {
             UpdatePlayerInformationsEvent();
         }
         return(this);
     }
     catch (VersionNotSupportedException ex)
     {
         while (!PlayTimer.Enabled)
         {
             PlayTimer.Start();
         }
         throw ex;
     }
     catch (System.Exception ex)
     {
         while (!PlayTimer.Enabled)
         {
             PlayTimer.Start();
         }
         throw ex;
     }
 }