Esempio n. 1
0
        //Change value in existing .dat file for a book
        private static void BookInfoSet(string key, object value, string bookFile)
        {
            try
            {
                var bookData = BookKeeper.GetData(bookFile);

                if ((typeof(BookData)).GetField("Sync") == null)
                {
                    return;
                }

                typeof(BookData).GetField(key).SetValue(bookData, value);
                BookKeeper.SaveData(bookData);
            }
            catch (Exception e)
            {
                DebugConsole.WriteLine("Edit book: It was not possible to save the provided book data: " + e.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Save data from the EditBook fields into the database
        /// </summary>
        /// <param name="key">Name of the BookData field to which to save the data</param>
        /// <param name="value">Value to be saved into the specified field</param>
        private void BookInfoSet(string key, object value)
        {
            if (_bookData == null)
            {
                return;
            }

            typeof(BookData).GetField(key).SetValue(_bookData, value);

            try
            {
                BookKeeper.SaveData(_bookData);
            }
            catch (Exception e)
            {
                MainWindow.Info(String.Format(UiLang.Get("DatFileNotAvailable"), _bookData.Title), 1);
                DebugConsole.WriteLine("Edit book: It was not possible to save the provided value into the data file: " + e.Message);
                Close();
            }
        }