diff --git a/TJAPlayer3/Common/CSavableT.cs b/TJAPlayer3/Common/CSavableT.cs new file mode 100644 index 00000000..48be9afe --- /dev/null +++ b/TJAPlayer3/Common/CSavableT.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + + +namespace TJAPlayer3 +{ + class CSavableT where T : new() + { + public virtual string _fn + { + get; + protected set; + } + public void tDBInitSavable() + { + if (!File.Exists(_fn)) + tSaveFile(); + + tLoadFile(); + } + + public T data = new T(); + + #region [private] + + private void tSaveFile() + { + ConfigManager.SaveConfig(data, _fn); + } + + private void tLoadFile() + { + data = ConfigManager.GetConfig(_fn); + } + + #endregion + + } +} diff --git a/TJAPlayer3/Databases/DBCDN.cs b/TJAPlayer3/Databases/DBCDN.cs index 3f9b4046..ba1dc78c 100644 --- a/TJAPlayer3/Databases/DBCDN.cs +++ b/TJAPlayer3/Databases/DBCDN.cs @@ -4,9 +4,15 @@ using Newtonsoft.Json; namespace TJAPlayer3 { - class DBCDN + class DBCDN : CSavableT> { + public DBCDN() + { + _fn = @".\Databases\CDN.json"; + base.tDBInitSavable(); + } + /* public void tDBCDN() { if (!File.Exists(@".\Databases\CDN.json")) @@ -14,6 +20,7 @@ namespace TJAPlayer3 tLoadFile(); } + */ #region [Auxiliary classes] @@ -67,8 +74,10 @@ namespace TJAPlayer3 #endregion + /* public Dictionary data = new Dictionary(); + #region [private] private void tSaveFile() @@ -82,5 +91,6 @@ namespace TJAPlayer3 } #endregion + */ } } \ No newline at end of file diff --git a/TJAPlayer3/Databases/DBEncyclopediaMenus.cs b/TJAPlayer3/Databases/DBEncyclopediaMenus.cs new file mode 100644 index 00000000..7d43fa58 --- /dev/null +++ b/TJAPlayer3/Databases/DBEncyclopediaMenus.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +namespace TJAPlayer3 +{ + class DBEncyclopediaMenus : CSavableT> + { + public DBEncyclopediaMenus() + { + _fn = @".\Encyclopedia\Menus.json"; + base.tDBInitSavable(); + } + + + } +} diff --git a/TJAPlayer3/Databases/Databases.cs b/TJAPlayer3/Databases/Databases.cs index ebebd718..74f557a4 100644 --- a/TJAPlayer3/Databases/Databases.cs +++ b/TJAPlayer3/Databases/Databases.cs @@ -8,8 +8,6 @@ namespace TJAPlayer3 public void tDatabases() { DBCDN = new DBCDN(); - - DBCDN.tDBCDN(); } public DBCDN DBCDN; diff --git a/TJAPlayer3/TJAPlayer3.csproj b/TJAPlayer3/TJAPlayer3.csproj index 0299d720..3208d7b9 100644 --- a/TJAPlayer3/TJAPlayer3.csproj +++ b/TJAPlayer3/TJAPlayer3.csproj @@ -126,6 +126,7 @@ + @@ -137,6 +138,7 @@ + @@ -407,7 +409,9 @@ 4.5.0 - + + +