示例#1
0
        /// <summary>
        /// Ustawia stan Battlemapy w bazie na podany
        /// </summary>
        /// <param name="newModel"></param>
        public static void UpdateRecord(BattleMapModel newModel)
        {
            string fullPath = FileIO.GetProgDataPath(dataPath);

            //konwersja na InutModel
            BattleMapInputModel ioModel = new BattleMapInputModel(newModel);

            //serializacja i zapis
            string output = JsonConvert.SerializeObject(ioModel);

            FileIO.WriteText(fullPath, output);
        }
示例#2
0
        private static readonly string dataPath = "DataBase/BattleMapData.json"; //ścieżka względna pliku bazy danych

        /// <summary>
        /// Pobiera ztan Battlemapy z bazy
        /// </summary>
        /// <returns></returns>
        public static BattleMapModel GetData()
        {
            BattleMapModel data = new BattleMapModel();

            string fullPath = FileIO.GetProgDataPath(dataPath);

            //deseralizacja rekordu
            BattleMapInputModel rawData = JsonConvert.DeserializeObject <BattleMapInputModel>(FileIO.ReadTxt(fullPath));

            //konwersja z InputModelu
            data = rawData.ToLogic();

            return(data);
        }