@@ -21,9 +21,9 @@ public class XivCache
21
21
{
22
22
private GameInfo _gameInfo ;
23
23
private DirectoryInfo _dbPath ;
24
- private static readonly Version CacheVersion = new Version ( "0.0.0.25" ) ;
24
+ public static readonly Version CacheVersion = new Version ( "0.0.0.25" ) ;
25
25
private const string dbFileName = "mod_cache.db" ;
26
- private const string creationScript = "CreateDB .sql" ;
26
+ private const string creationScript = "CreateCacheDB .sql" ;
27
27
private string _connectionString { get
28
28
{
29
29
return "Data Source=" + _dbPath + ";Pooling=True;Max Pool Size=100;" ;
@@ -814,6 +814,11 @@ private string GetMetaValue(string key)
814
814
return val ? . ToString ( ) ;
815
815
}
816
816
817
+ private async Task < List < T > > BuildListFromTable < T > ( string table , WhereClause where , Func < CacheReader , Task < T > > func )
818
+ {
819
+ return await BuildListFromTable < T > ( _connectionString , table , where , func ) ;
820
+ }
821
+
817
822
/// <summary>
818
823
/// Creates a list from the data entries in a cache table, using the given where clause and predicate.
819
824
/// </summary>
@@ -822,10 +827,10 @@ private string GetMetaValue(string key)
822
827
/// <param name="where"></param>
823
828
/// <param name="func"></param>
824
829
/// <returns></returns>
825
- private async Task < List < T > > BuildListFromTable < T > ( string table , WhereClause where , Func < CacheReader , Task < T > > func )
830
+ public static async Task < List < T > > BuildListFromTable < T > ( string connectionString , string table , WhereClause where , Func < CacheReader , Task < T > > func )
826
831
{
827
832
List < T > list = new List < T > ( ) ;
828
- using ( var db = new SQLiteConnection ( _connectionString ) )
833
+ using ( var db = new SQLiteConnection ( connectionString ) )
829
834
{
830
835
db . Open ( ) ;
831
836
// Check how large the result set will be so we're not constantly
@@ -886,7 +891,7 @@ private async Task<List<T>> BuildListFromTable<T>(string table, WhereClause wher
886
891
/// A [WhereClause] with any [Inner] entries is considered
887
892
/// a parenthetical group and has its own Column/Value/Comparer ignored.
888
893
/// </summary>
889
- private class WhereClause
894
+ public class WhereClause
890
895
{
891
896
public enum ComparisonType
892
897
{
@@ -1018,7 +1023,7 @@ public void AddParameters(SQLiteCommand cmd)
1018
1023
/// ensures the underlying reader is properly closed and destroyed to help
1019
1024
/// avoid lingering file handles.
1020
1025
/// </summary>
1021
- private class CacheReader : IDisposable
1026
+ public class CacheReader : IDisposable
1022
1027
{
1023
1028
private SQLiteDataReader _reader ;
1024
1029
private Dictionary < string , int > _headers ;
@@ -1058,6 +1063,24 @@ public CacheReader(SQLiteDataReader reader)
1058
1063
}
1059
1064
}
1060
1065
1066
+ public byte GetByte ( string fieldName )
1067
+ {
1068
+ if ( _reader [ _headers [ fieldName ] ] . GetType ( ) == NullType )
1069
+ {
1070
+ return 0 ;
1071
+ }
1072
+ return _reader . GetByte ( _headers [ fieldName ] ) ;
1073
+ }
1074
+
1075
+ public float GetFloat ( string fieldName )
1076
+ {
1077
+ if ( _reader [ _headers [ fieldName ] ] . GetType ( ) == NullType )
1078
+ {
1079
+ return 0f ;
1080
+ }
1081
+ return _reader . GetFloat ( _headers [ fieldName ] ) ;
1082
+ }
1083
+
1061
1084
public int GetInt32 ( string fieldName )
1062
1085
{
1063
1086
if ( _reader [ _headers [ fieldName ] ] . GetType ( ) == NullType )
0 commit comments