diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..6d1d40b9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "sqlite-net"] + path = sqlite-net + url = https://github.com/heyzooi/sqlite-net.git diff --git a/Kinvey-Xamarin-Android/Client/AndroidClientBuilder.cs b/Kinvey-Xamarin-Android/Client/AndroidClientBuilder.cs index 995202d0..48fbe95d 100644 --- a/Kinvey-Xamarin-Android/Client/AndroidClientBuilder.cs +++ b/Kinvey-Xamarin-Android/Client/AndroidClientBuilder.cs @@ -1,5 +1,4 @@ using System; -using SQLite.Net.Platform.XamarinAndroid; namespace Kinvey { @@ -9,7 +8,6 @@ public AndroidClientBuilder(string appKey, string appSecret) : base(appKey, appSecret, Constants.DevicePlatform.Android) { this.setFilePath(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)); - this.setOfflinePlatform(new SQLitePlatformAndroid()); } } } diff --git a/Kinvey-Xamarin-Android/Kinvey-Xamarin-Android.csproj b/Kinvey-Xamarin-Android/Kinvey-Xamarin-Android.csproj index e74d4f16..722fa652 100644 --- a/Kinvey-Xamarin-Android/Kinvey-Xamarin-Android.csproj +++ b/Kinvey-Xamarin-Android/Kinvey-Xamarin-Android.csproj @@ -13,7 +13,7 @@ Resources\Resource.designer.cs false Kinvey-Xamarin-Android - v7.0 + v5.1 @@ -42,28 +42,19 @@ - - ..\packages\Xamarin.GooglePlayServices.Basement.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Basement.dll - - - ..\packages\Xamarin.GooglePlayServices.Base.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Base.dll - - - ..\packages\Xamarin.GooglePlayServices.Gcm.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Gcm.dll + + ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll + - ..\packages\Xamarin.Android.Support.v4.23.1.1.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll + ..\packages\Xamarin.Android.Support.v4.22.2.0.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll + + ..\packages\Xamarin.GooglePlayServices.Base.25.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Base.dll - - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll + + ..\packages\Xamarin.GooglePlayServices.Gcm.25.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Gcm.dll - @@ -93,5 +84,9 @@ {6644D98D-026B-48E9-95A3-61C4D98D82E7} Kinvey.Core + + {32711A14-971C-4A96-90B3-00A2D1E28E0D} + SQLite-net-std + \ No newline at end of file diff --git a/Kinvey-Xamarin-Android/packages.config b/Kinvey-Xamarin-Android/packages.config index a1e2a34b..97632db7 100644 --- a/Kinvey-Xamarin-Android/packages.config +++ b/Kinvey-Xamarin-Android/packages.config @@ -2,10 +2,7 @@ - - - - - - + + + \ No newline at end of file diff --git a/Kinvey-Xamarin-iOS/Client/IOSClientBuilder.cs b/Kinvey-Xamarin-iOS/Client/IOSClientBuilder.cs index ed4af44c..373b95f5 100644 --- a/Kinvey-Xamarin-iOS/Client/IOSClientBuilder.cs +++ b/Kinvey-Xamarin-iOS/Client/IOSClientBuilder.cs @@ -1,5 +1,4 @@ using Foundation; -using SQLite.Net.Platform.XamarinIOS; namespace Kinvey { @@ -9,7 +8,6 @@ public IOSClientBuilder(string appKey, string appSecret) : base(appKey, appSecret, Constants.DevicePlatform.iOS) { this.setFilePath(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].ToString()); - this.setOfflinePlatform(new SQLitePlatformIOS()); } } } diff --git a/Kinvey-Xamarin-iOS/Kinvey-Xamarin-iOS.csproj b/Kinvey-Xamarin-iOS/Kinvey-Xamarin-iOS.csproj index 99fe060b..fc4f6a0e 100644 --- a/Kinvey-Xamarin-iOS/Kinvey-Xamarin-iOS.csproj +++ b/Kinvey-Xamarin-iOS/Kinvey-Xamarin-iOS.csproj @@ -44,12 +44,6 @@ - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\Xamarin.iOS10\SQLite.Net.Platform.XamarinIOS.Unified.dll - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll diff --git a/Kinvey-Xamarin-iOS/packages.config b/Kinvey-Xamarin-iOS/packages.config index b064f527..07190e50 100644 --- a/Kinvey-Xamarin-iOS/packages.config +++ b/Kinvey-Xamarin-iOS/packages.config @@ -8,8 +8,6 @@ - - diff --git a/Kinvey.Core/Auth/SQLCredential.cs b/Kinvey.Core/Auth/SQLCredential.cs index 72e8c420..10055ed2 100644 --- a/Kinvey.Core/Auth/SQLCredential.cs +++ b/Kinvey.Core/Auth/SQLCredential.cs @@ -11,7 +11,7 @@ // Unauthorized reproduction, transmission or distribution of this file and its // contents is a violation of applicable laws. -using SQLite.Net.Attributes; +using SQLite; /// /// SQL credential. diff --git a/Kinvey.Core/Auth/SQLiteCredentialStore.cs b/Kinvey.Core/Auth/SQLiteCredentialStore.cs index 9bde9965..cda9298f 100644 --- a/Kinvey.Core/Auth/SQLiteCredentialStore.cs +++ b/Kinvey.Core/Auth/SQLiteCredentialStore.cs @@ -12,8 +12,7 @@ // contents is a violation of applicable laws. using System.IO; -using SQLite.Net.Interop; -using SQLite.Net; +using SQLite; using System.Collections.Generic; using Newtonsoft.Json.Linq; using Newtonsoft.Json; @@ -35,12 +34,12 @@ public class SQLiteCredentialStore : ICredentialStore /// /// Platform. /// Filepath. - public SQLiteCredentialStore (ISQLitePlatform platform, string filepath) + public SQLiteCredentialStore (string filepath) { - string dbPath = Path.Combine (filepath, "kinvey_tokens.sqlite"); if (_dbConnection == null) { - _dbConnection = new SQLiteConnection (platform, dbPath); + var dbPath = Path.Combine(filepath, "kinvey_tokens.sqlite"); + _dbConnection = new SQLiteConnection (dbPath); _dbConnection.CreateTable(); } } diff --git a/Kinvey.Core/Client/Client.cs b/Kinvey.Core/Client/Client.cs index 2b3a1f0e..0ec933b1 100644 --- a/Kinvey.Core/Client/Client.cs +++ b/Kinvey.Core/Client/Client.cs @@ -13,7 +13,7 @@ using System; using System.Collections.Generic; -using SQLite.Net.Interop; +using SQLite; using System.Threading.Tasks; using KinveyUtils; using Newtonsoft.Json; @@ -133,12 +133,6 @@ internal PingRequest(AbstractClient client, Dictionary urlProper /// The file path. private string filePath {get; set;} - /// - ///a reference to the sqlite implementation -- going to be platform dependent - /// - /// The offline platform. - private ISQLitePlatform offlinePlatform {get; set;} - private ICacheManager CacheManager {get; set; } /// @@ -173,16 +167,16 @@ public Builder(string appKey, string appSecret, Constants.DevicePlatform deviceP /// public virtual Client Build() { - if (this.filePath != null && offlinePlatform != null) + if (this.filePath != null) { if (this.Store == null) { - this.Store = new SQLiteCredentialStore (offlinePlatform, filePath); + this.Store = new SQLiteCredentialStore (filePath); } if (this.CacheManager == null) { - this.CacheManager = new SQLiteCacheManager (offlinePlatform, filePath); + this.CacheManager = new SQLiteCacheManager (filePath); } } @@ -265,16 +259,6 @@ public Builder setFilePath(string path){ this.filePath = path; return this; } - - /// - /// Set the sqlite implementation to use for offline. - /// - /// The offline platform. - /// Platform. - public Builder setOfflinePlatform(ISQLitePlatform platform){ - this.offlinePlatform = platform; - return this; - } /// /// Sets the logger action -- the ClientLogger class uses this to write to logs. diff --git a/Kinvey.Core/Kinvey.Core.csproj b/Kinvey.Core/Kinvey.Core.csproj index 21bf19f6..8de0b7e8 100644 --- a/Kinvey.Core/Kinvey.Core.csproj +++ b/Kinvey.Core/Kinvey.Core.csproj @@ -173,12 +173,6 @@ ..\packages\Remotion.Linq.2.0.1\lib\portable-net45+win+wpa81+wp80\Remotion.Linq.dll - - ..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - ..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll @@ -191,5 +185,9 @@ {444456B1-5B55-48D6-9637-00ADCA92B7C9} Kinvey-Utils + + {7F946494-8EE0-432B-8A87-98961143D5C1} + SQLite-net + \ No newline at end of file diff --git a/Kinvey.Core/Model/AccessControlList.cs b/Kinvey.Core/Model/AccessControlList.cs index 28fcb484..da3757d0 100644 --- a/Kinvey.Core/Model/AccessControlList.cs +++ b/Kinvey.Core/Model/AccessControlList.cs @@ -12,8 +12,8 @@ // contents is a violation of applicable laws. using System.Collections.Generic; +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net; namespace Kinvey { @@ -24,7 +24,8 @@ namespace Kinvey /// the collection level. /// [JsonObject] - public class AccessControlList : ISerializable + [DataContract] + public class AccessControlList { /// /// the field name within every JSON object. @@ -36,6 +37,7 @@ public class AccessControlList : ISerializable /// /// The creator [JsonProperty("creator")] + [DataMember(Name = "creator")] public string Creator { get; set; } /// @@ -43,28 +45,32 @@ public class AccessControlList : ISerializable /// /// true if globally readable; otherwise, false. [JsonProperty("gr")] - public bool GloballyReadable { get; set; } + [DataMember(Name = "gr")] + public bool GloballyReadable { get; set; } /// /// Gets or sets whether this entity is globally writeable. /// /// true if globally writeable; otherwise, false. [JsonProperty("gw")] - public bool GloballyWriteable { get; set; } + [DataMember(Name = "gw")] + public bool GloballyWriteable { get; set; } /// /// Gets or sets a list of user IDs that are specifically allowed to read this entity. /// /// The list of user IDs allowed to read this entity. [JsonProperty("r")] - public List Readers { get; set; } + [DataMember(Name = "r")] + public List Readers { get; set; } /// /// Gets or sets a list of user IDs that are specifically allowed to modify this entity. /// /// The list of user IDs allowed to modify this entity. [JsonProperty("w")] - public List Writers { get; set; } + [DataMember(Name = "w")] + public List Writers { get; set; } /// /// Gets or sets the ACL group that contains lists of user groups which are authorized on the @@ -74,13 +80,15 @@ public class AccessControlList : ISerializable /// /// The group object which contains the list of user groups allowed to read and/or modify the entity. [JsonProperty("groups")] - public ACLGroups Groups { get; set; } + [DataMember(Name = "groups")] + public ACLGroups Groups { get; set; } /// /// Class that holds the list of user groups that can read the entity and the list of user groups /// that can modify the entity. /// [JsonObject] + [DataContract] public class ACLGroups { /// @@ -88,14 +96,16 @@ public class ACLGroups /// /// The list of user groups with read access to the entity. [JsonProperty("r")] - public List Readers { get; set; } + [DataMember(Name = "r")] + public List Readers { get; set; } /// /// Gets or sets the list of user groups that can modify the entity. /// /// The list of user groups with write access to the entity. [JsonProperty("w")] - public List Writers { get; set; } + [DataMember(Name = "w")] + public List Writers { get; set; } public ACLGroups() { @@ -113,13 +123,5 @@ public AccessControlList() Groups = new ACLGroups(); } - - /// - /// Implementation of ISerializeable interface, used to serialize this instance. - /// - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } } } diff --git a/Kinvey.Core/Model/Entity.cs b/Kinvey.Core/Model/Entity.cs index a1d58c37..fb892c91 100644 --- a/Kinvey.Core/Model/Entity.cs +++ b/Kinvey.Core/Model/Entity.cs @@ -11,8 +11,9 @@ // Unauthorized reproduction, transmission or distribution of this file and its // contents is a violation of applicable laws. +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; namespace Kinvey { /// @@ -20,14 +21,16 @@ namespace Kinvey /// interface /// [JsonObject(MemberSerialization.OptIn)] - public class Entity : IPersistable + [DataContract] + public class Entity : IPersistable { /// /// Gets or sets the Kinvey ID. /// /// The identifier. [JsonProperty("_id")] - [Preserve] + [DataMember(Name = "_id")] + [Preserve] [PrimaryKey, Column("_id")] public string ID { get; set; } @@ -36,7 +39,8 @@ public class Entity : IPersistable /// /// The acl. [JsonProperty("_acl")] - [Preserve] + [DataMember(Name = "_acl")] + [Preserve] [Column("_acl")] public AccessControlList ACL { get; set; } @@ -45,13 +49,9 @@ public class Entity : IPersistable /// /// The kmd. [JsonProperty("_kmd")] - [Preserve] + [DataMember(Name = "_kmd")] + [Preserve] [Column("_kmd")] public KinveyMetaData KMD { get; set; } - - virtual public string Serialize() - { - return JsonConvert.SerializeObject(this); - } } } diff --git a/Kinvey.Core/Model/IPersistable.cs b/Kinvey.Core/Model/IPersistable.cs index ca264a4c..ab8bd370 100644 --- a/Kinvey.Core/Model/IPersistable.cs +++ b/Kinvey.Core/Model/IPersistable.cs @@ -11,15 +11,13 @@ // Unauthorized reproduction, transmission or distribution of this file and its // contents is a violation of applicable laws. -using SQLite.Net; - namespace Kinvey { /// /// Persistable interface which model objects can choose to implement as an alternative /// to subclassing from /// - public interface IPersistable : ISerializable + public interface IPersistable { /// /// ID field which maps back to Kinvey _id diff --git a/Kinvey.Core/Model/KMDEmailVerification.cs b/Kinvey.Core/Model/KMDEmailVerification.cs index c51e0179..be3697d0 100644 --- a/Kinvey.Core/Model/KMDEmailVerification.cs +++ b/Kinvey.Core/Model/KMDEmailVerification.cs @@ -12,8 +12,8 @@ // contents is a violation of applicable laws. using System; +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net; namespace Kinvey { @@ -22,7 +22,8 @@ namespace Kinvey /// entities stored in Kinvey that have verified through email /// [JsonObject(MemberSerialization.OptIn)] - public class KMDEmailVerification : ISerializable + [DataContract] + public class KMDEmailVerification { /// /// Initializes a new instance of the class. @@ -37,6 +38,7 @@ public KMDEmailVerification() /// [Preserve] [JsonProperty("status")] + [DataMember(Name = "status")] public String Status { get; set; } /// @@ -44,28 +46,23 @@ public KMDEmailVerification() /// [Preserve] [JsonProperty("lastStateChangeAt")] - public String LastStateChangeAt { get; set; } + [DataMember(Name = "lastStateChangeAt")] + public String LastStateChangeAt { get; set; } /// /// Gets or sets the last time when email verification was confirmed. /// [Preserve] [JsonProperty("lastConfirmedAt")] - public String LastConfirmedAt { get; set; } + [DataMember(Name = "lastConfirmedAt")] + public String LastConfirmedAt { get; set; } /// /// Gets or sets the email address of the user used for email verification. /// [Preserve] [JsonProperty("emailAddress")] - public String EmailAddress { get; set; } - - /// - /// Serialize this instance of in the local cache. - /// - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } + [DataMember(Name = "emailAddress")] + public String EmailAddress { get; set; } } } diff --git a/Kinvey.Core/Model/KMDPasswordReset.cs b/Kinvey.Core/Model/KMDPasswordReset.cs index 44b9719e..581257de 100644 --- a/Kinvey.Core/Model/KMDPasswordReset.cs +++ b/Kinvey.Core/Model/KMDPasswordReset.cs @@ -12,8 +12,8 @@ // contents is a violation of applicable laws. using System; +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net; namespace Kinvey { @@ -22,7 +22,8 @@ namespace Kinvey /// entities stored in Kinvey that have verified through email /// [JsonObject(MemberSerialization.OptIn)] - public class KMDPasswordReset : ISerializable + [DataContract] + public class KMDPasswordReset { /// /// Initializes a new instance of the class. @@ -38,6 +39,7 @@ public KMDPasswordReset() /// [Preserve] [JsonProperty("status")] + [DataMember(Name = "status")] public String Status { get; set; } /// @@ -47,14 +49,7 @@ public KMDPasswordReset() /// [Preserve] [JsonProperty("lastStateChangeAt")] - public String LastStateChangeAt { get; set; } - - /// - /// Serialize this instance of in the local cache. - /// - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } + [DataMember(Name = "lastStateChangeAt")] + public String LastStateChangeAt { get; set; } } } diff --git a/Kinvey.Core/Model/KMDStatus.cs b/Kinvey.Core/Model/KMDStatus.cs index 8e95e709..b1962244 100644 --- a/Kinvey.Core/Model/KMDStatus.cs +++ b/Kinvey.Core/Model/KMDStatus.cs @@ -12,8 +12,8 @@ // contents is a violation of applicable laws. using System; +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net; namespace Kinvey { @@ -22,7 +22,8 @@ namespace Kinvey /// entities stored in Kinvey that have verified through email /// [JsonObject(MemberSerialization.OptIn)] - public class KMDStatus : ISerializable + [DataContract] + public class KMDStatus { /// /// Initializes a new instance of the class. @@ -52,6 +53,7 @@ public EnumUserStatus UserEnabledState /// [Preserve] [JsonProperty("val")] + [DataMember(Name = "val")] public String Value { get; set; } /// @@ -61,15 +63,8 @@ public EnumUserStatus UserEnabledState /// [Preserve] [JsonProperty("lastChange")] - public String LastChange { get; set; } - - /// - /// Serialize this instance of in the local cache. - /// - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } + [DataMember(Name = "lastChange")] + public String LastChange { get; set; } } public enum EnumUserStatus diff --git a/Kinvey.Core/Model/KinveyMetaData.cs b/Kinvey.Core/Model/KinveyMetaData.cs index 2a4f0230..59ab84ba 100644 --- a/Kinvey.Core/Model/KinveyMetaData.cs +++ b/Kinvey.Core/Model/KinveyMetaData.cs @@ -12,8 +12,8 @@ // contents is a violation of applicable laws. using System; +using System.Runtime.Serialization; using Newtonsoft.Json; -using SQLite.Net; namespace Kinvey { @@ -21,7 +21,8 @@ namespace Kinvey /// JSON representation of the _kmd field present on every entity stored in Kinvey /// [JsonObject(MemberSerialization.OptIn)] - public class KinveyMetaData : ISerializable + [DataContract] + public class KinveyMetaData { /// /// Initializes a new instance of the class. @@ -42,6 +43,7 @@ public KinveyMetaData () /// The last modified time. [Preserve] [JsonProperty("lmt")] + [DataMember(Name = "lmt")] public String lastModifiedTime{get; set;} /// @@ -50,12 +52,8 @@ public KinveyMetaData () /// The entity creation time. [Preserve] [JsonProperty("ect")] - public String entityCreationTime{get; set;} - - - public string Serialize(){ - return JsonConvert.SerializeObject (this); - } + [DataMember(Name = "ect")] + public String entityCreationTime{get; set;} } } diff --git a/Kinvey.Core/Offline/CollectionTableMap.cs b/Kinvey.Core/Offline/CollectionTableMap.cs index 6249d11f..f6f13e62 100644 --- a/Kinvey.Core/Offline/CollectionTableMap.cs +++ b/Kinvey.Core/Offline/CollectionTableMap.cs @@ -12,7 +12,7 @@ // contents is a violation of applicable laws. using System; -using SQLite.Net.Attributes; +using SQLite; namespace Kinvey { diff --git a/Kinvey.Core/Offline/ICacheManager.cs b/Kinvey.Core/Offline/ICacheManager.cs index 524b7cc9..d63837bd 100644 --- a/Kinvey.Core/Offline/ICacheManager.cs +++ b/Kinvey.Core/Offline/ICacheManager.cs @@ -12,18 +12,12 @@ // contents is a violation of applicable laws. using System; -using SQLite.Net.Interop; +using SQLite; namespace Kinvey { public interface ICacheManager { - /// - /// Gets or sets the platform. - /// - /// The platform. - ISQLitePlatform platform {get; set;} - /// /// Gets or sets the dbpath. /// @@ -35,7 +29,7 @@ public interface ICacheManager /// /// The cache. /// Collection name. - ICache GetCache (string collectionName) where T:class; + ICache GetCache (string collectionName) where T : class, new(); ISyncQueue GetSyncQueue (string collectionName); diff --git a/Kinvey.Core/Offline/PendingWriteAction.cs b/Kinvey.Core/Offline/PendingWriteAction.cs index ca68a2f8..934aa0f4 100644 --- a/Kinvey.Core/Offline/PendingWriteAction.cs +++ b/Kinvey.Core/Offline/PendingWriteAction.cs @@ -12,7 +12,7 @@ // contents is a violation of applicable laws. using System; -using SQLite.Net.Attributes; +using SQLite; using Newtonsoft.Json; namespace Kinvey diff --git a/Kinvey.Core/Offline/QueryCacheItem.cs b/Kinvey.Core/Offline/QueryCacheItem.cs index 90f70ba7..84485da3 100644 --- a/Kinvey.Core/Offline/QueryCacheItem.cs +++ b/Kinvey.Core/Offline/QueryCacheItem.cs @@ -12,7 +12,7 @@ // contents is a violation of applicable laws. using System; -using SQLite.Net.Attributes; +using SQLite; using Newtonsoft.Json; namespace Kinvey diff --git a/Kinvey.Core/Offline/SQLTemplates.cs b/Kinvey.Core/Offline/SQLTemplates.cs index 7ed8dd57..be3930e7 100644 --- a/Kinvey.Core/Offline/SQLTemplates.cs +++ b/Kinvey.Core/Offline/SQLTemplates.cs @@ -13,7 +13,7 @@ using System; using System.Collections.Generic; -using SQLite.Net.Attributes; +using SQLite; using Newtonsoft.Json.Linq; namespace Kinvey diff --git a/Kinvey.Core/Offline/SQLiteCache.cs b/Kinvey.Core/Offline/SQLiteCache.cs index 3574c0df..5f30dada 100644 --- a/Kinvey.Core/Offline/SQLiteCache.cs +++ b/Kinvey.Core/Offline/SQLiteCache.cs @@ -16,12 +16,10 @@ using System.Collections.Generic; using System.ComponentModel; using System.Threading.Tasks; -using SQLite.Net.Async; -using SQLite.Net; +using SQLite; using System.Linq; using System.Linq.Expressions; using System.Runtime.Serialization; -using SQLite.Net.Interop; using System.Reflection; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -35,8 +33,8 @@ namespace Kinvey /// This class is responsible for breaking apart a request, and determing what actions to take /// Actual actions are performed on the OfflineTable class, using a SQLiteDatabaseHelper /// - public class SQLiteCache : ICache where T:class - { + public class SQLiteCache : ICache where T : class, new() + { private string collectionName; @@ -44,29 +42,26 @@ public class SQLiteCache : ICache where T:class private SQLiteConnection dbConnectionSync; - private ISQLitePlatform platform; - /// /// Initializes a new instance of the class. /// /// Collection. /// Connection. - public SQLiteCache(string collection, SQLiteAsyncConnection connectionAsync, SQLiteConnection connectionSync, ISQLitePlatform platform) + public SQLiteCache(string collection, SQLiteAsyncConnection connectionAsync, SQLiteConnection connectionSync) { this.collectionName = collection; // this.dbConnectionAsync = connectionAsync; this.dbConnectionSync = connectionSync; - this.platform = platform; //dropTable(); createTable(); } // Creates an SQLite table, which manages the local representation of the connection. - private int createTable() + private void createTable() { //dbConnection.CreateTableAsync (); - int retVal = dbConnectionSync.CreateTable(); + dbConnectionSync.CreateTable(); //set primary key // IEnumerable props = platform.ReflectionService.GetPublicInstanceProperties (typeof (T)); @@ -87,8 +82,6 @@ private int createTable() // } // } // } - - return retVal; } @@ -101,7 +94,7 @@ private int dropTable() public bool IsCacheEmpty() { - return dbConnectionSync.Table().Count() == 0; + return dbConnectionSync.Table().Count() == 0; } #region SQLite Cache CRUD APIs @@ -185,7 +178,7 @@ public T UpdateCacheSave(T item, string tempID) public List FindAll() { - return dbConnectionSync.Table().ToList(); + return dbConnectionSync.Table().ToList(); } public int CountAll() @@ -199,7 +192,7 @@ public T FindByID(string ID) T item = default(T); try { - item = dbConnectionSync.Get(ID); + item = dbConnectionSync.Get(ID); } catch (Exception e) { @@ -533,7 +526,12 @@ public List RefreshCache(List items) { try { - dbConnectionSync.InsertOrReplaceAll(items); + dbConnectionSync.RunInTransaction(() => { + foreach (var item in items) + { + dbConnectionSync.InsertOrReplace(item); + } + }); } catch (SQLiteException e) { diff --git a/Kinvey.Core/Offline/SQLiteCacheManager.cs b/Kinvey.Core/Offline/SQLiteCacheManager.cs index 677d4272..87cfa2d9 100644 --- a/Kinvey.Core/Offline/SQLiteCacheManager.cs +++ b/Kinvey.Core/Offline/SQLiteCacheManager.cs @@ -20,9 +20,7 @@ using KinveyUtils; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SQLite.Net; -using SQLite.Net.Async; -using SQLite.Net.Interop; +using SQLite; namespace Kinvey { @@ -32,7 +30,7 @@ namespace Kinvey public class SQLiteCacheManager : ICacheManager { - private class DebugTraceListener : ITraceListener + private class DebugTraceListener { public void Receive(string message) { @@ -60,11 +58,9 @@ private SQLiteConnection DBConnectionSync //var connectionFactory = new Func(()=>new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(this.dbpath, false, null, new KinveyContractResolver()))); //dbConnection = new SQLiteAsyncConnection (connectionFactory); _dbConnectionSync = new SQLiteConnection( - sqlitePlatform: platform, databasePath: dbpath, openFlags: SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex, - storeDateTimeAsTicks: false, - resolver: new KinveyContractResolver() + storeDateTimeAsTicks: false ); //_dbConnectionSync.TraceListener = new DebugTraceListener(); } @@ -74,12 +70,6 @@ private SQLiteConnection DBConnectionSync } } - /// - /// Gets or sets the platform. - /// - /// The platform. - public ISQLitePlatform platform { get; set; } - /// /// Gets or sets the database file path. /// @@ -89,9 +79,8 @@ private SQLiteConnection DBConnectionSync /// /// Initializes a new instance of the class. /// - public SQLiteCacheManager(ISQLitePlatform platform, string filePath) + public SQLiteCacheManager(string filePath) { - this.platform = platform; this.dbpath = Path.Combine (filePath, "kinveyOffline.sqlite"); } @@ -169,7 +158,7 @@ public void clearStorage() // return SQLiteHelper.getInstance (platform, dbpath); // } - public ICache GetCache(string collectionName) where T : class + public ICache GetCache(string collectionName) where T : class, new() { lock (DBConnectionSync) { @@ -189,7 +178,7 @@ public ICache GetCache(string collectionName) where T : class return mapCollectionToCache[collectionName] as ICache; } - mapCollectionToCache[collectionName] = new SQLiteCache(collectionName, dbConnectionAsync, DBConnectionSync, platform); + mapCollectionToCache[collectionName] = new SQLiteCache(collectionName, dbConnectionAsync, DBConnectionSync); return mapCollectionToCache[collectionName] as ICache; } } @@ -317,28 +306,5 @@ public static bool TableExists (SQLiteConnection connection) return cmd.ExecuteScalar () != null; } - - /// - /// Kinvey contract resolver - this resolver is used to replace the default SQLite resolver, - /// so that any class that can be serialized / deserialized as a JSON string can be stored in SQL - /// - class KinveyContractResolver:ContractResolver{ - - public KinveyContractResolver () : base(t => true, Deserialize){ - - } - - public static object Deserialize(Type t, object [] obj){ - //if (t == typeof(ISerializable)) { - if (t.GetTypeInfo().ImplementedInterfaces.Contains(typeof (ISerializable)) && - obj != null && - obj.Count() > 0) - { - return JsonConvert.DeserializeObject (obj[0].ToString(), t); - } - - return Activator.CreateInstance(t, obj); - } - } } } diff --git a/Kinvey.Core/Offline/SQLiteSyncQueue.cs b/Kinvey.Core/Offline/SQLiteSyncQueue.cs index 35c328d2..01714583 100644 --- a/Kinvey.Core/Offline/SQLiteSyncQueue.cs +++ b/Kinvey.Core/Offline/SQLiteSyncQueue.cs @@ -13,7 +13,7 @@ using System; using System.Collections.Generic; -using SQLite.Net; +using SQLite; using System.Threading.Tasks; diff --git a/Kinvey.Core/Store/DataStore.cs b/Kinvey.Core/Store/DataStore.cs index a7428fb8..5c4eab8c 100644 --- a/Kinvey.Core/Store/DataStore.cs +++ b/Kinvey.Core/Store/DataStore.cs @@ -25,7 +25,7 @@ namespace Kinvey /// Each DataStore in your application represents a collection on your backend. The DataStore class manages the access of data between the Kinvey backend and the app. /// The DataStore provides simple CRUD operations on data, as well as powerful querying and synchronization APIs. /// - public class DataStore : KinveyQueryable where T:class + public class DataStore : KinveyQueryable where T : class, new() { #region Member variables @@ -292,7 +292,7 @@ public async Task> FindWithMongoQueryAsync(string queryString) FindRequest findByQueryRequest = new FindRequest(client, collectionName, cache, storeType.ReadPolicy, DeltaSetFetchingEnabled, cacheDelegate, null, listIDs); ct.ThrowIfCancellationRequested(); var results = await findByQueryRequest.ExecuteAsync(); - return results?.FirstOrDefault(); + return results.FirstOrDefault(); } #region Grouping/Aggregate Functions @@ -302,7 +302,7 @@ public async Task> FindWithMongoQueryAsync(string queryString) /// /// The async task which returns the count. /// [optional] CancellationToken used to cancel the request. - public async Task GetCountAsync(IQueryable query = null, KinveyDelegate cacheCount = null, CancellationToken ct = default(CancellationToken)) + public async Task GetCountAsync(IQueryable query = null, KinveyDelegate cacheCount = null, CancellationToken ct = default(CancellationToken)) { GetCountRequest getCountRequest = new GetCountRequest(client, collectionName, cache, storeType.ReadPolicy, DeltaSetFetchingEnabled, cacheCount, query); ct.ThrowIfCancellationRequested(); @@ -318,7 +318,7 @@ public async Task> FindWithMongoQueryAsync(string queryString) /// [optional] Query used to filter results prior to aggregation. /// Delegate used to return the sum aggregate value based on what is available in offline cache. /// [optional] CancellationToken used to cancel the request. - public async Task> GroupAndAggregateAsync(EnumReduceFunction reduceFunction, string groupField = "", string aggregateField = "", IQueryable query = null, KinveyDelegate> cacheDelegate = null, CancellationToken ct = default(CancellationToken)) + public async Task> GroupAndAggregateAsync(EnumReduceFunction reduceFunction, string groupField = "", string aggregateField = "", IQueryable query = null, KinveyDelegate> cacheDelegate = null, CancellationToken ct = default(CancellationToken)) { FindAggregateRequest findByAggregateQueryRequest = new FindAggregateRequest(client, collectionName, reduceFunction, cache, storeType.ReadPolicy, DeltaSetFetchingEnabled, cacheDelegate, query, groupField, aggregateField); ct.ThrowIfCancellationRequested(); @@ -362,7 +362,7 @@ public async Task> FindWithMongoQueryAsync(string queryString) /// Entities that were pulled from the backend. /// Optional Query parameter. /// [optional] CancellationToken used to cancel the request. - public async Task> PullAsync(IQueryable query = null, int count = -1, bool isInitial = false, CancellationToken ct = default(CancellationToken)) + public async Task> PullAsync(IQueryable query = null, int count = -1, bool isInitial = false, CancellationToken ct = default(CancellationToken)) { if (this.storeType == DataStoreType.NETWORK) { @@ -415,7 +415,7 @@ public async Task> FindWithMongoQueryAsync(string queryString) /// DataStoreResponse indicating errors, if any. /// An optional query parameter that controls what gets pulled from the backend during a sync operation. /// [optional] CancellationToken used to cancel the request. - public async Task> SyncAsync(IQueryable query = null, CancellationToken ct = default(CancellationToken)) + public async Task> SyncAsync(IQueryable query = null, CancellationToken ct = default(CancellationToken)) { if (this.storeType == DataStoreType.NETWORK) { diff --git a/Kinvey.Core/Store/FindAggregateRequest.cs b/Kinvey.Core/Store/FindAggregateRequest.cs index c1aed5b4..243a217e 100644 --- a/Kinvey.Core/Store/FindAggregateRequest.cs +++ b/Kinvey.Core/Store/FindAggregateRequest.cs @@ -49,7 +49,7 @@ public FindAggregateRequest(AbstractClient client, ReadPolicy policy, bool deltaSetFetchingEnabled, KinveyDelegate> cacheDelegate, - IQueryable query, + IQueryable query, string groupField, string aggregateField) : base(client, collection, cache, query, policy, deltaSetFetchingEnabled) diff --git a/Kinvey.Core/Store/GetCountRequest.cs b/Kinvey.Core/Store/GetCountRequest.cs index 7275a457..65fdea32 100644 --- a/Kinvey.Core/Store/GetCountRequest.cs +++ b/Kinvey.Core/Store/GetCountRequest.cs @@ -74,7 +74,7 @@ private uint PerformLocalCount(KinveyDelegate localDelegate = null) { if (Query != null) { - IQueryable query = Query; + var query = Query; localCount = (uint)Cache.CountByQuery(query.Expression); } else diff --git a/Kinvey.Core/Store/ReadRequest.cs b/Kinvey.Core/Store/ReadRequest.cs index 5e40fcfa..e7dbb0d6 100644 --- a/Kinvey.Core/Store/ReadRequest.cs +++ b/Kinvey.Core/Store/ReadRequest.cs @@ -176,7 +176,7 @@ protected List PerformLocalFind(KinveyDelegate> localDelegate = null) { if (Query != null) { - IQueryable query = Query; + var query = Query; cacheHits = Cache.FindByQuery(query.Expression); } else if (EntityIDs?.Count > 0) diff --git a/Kinvey.Core/packages.config b/Kinvey.Core/packages.config index c15a1d1f..7299b6da 100644 --- a/Kinvey.Core/packages.config +++ b/Kinvey.Core/packages.config @@ -10,9 +10,6 @@ - - - diff --git a/Kinvey.Net/Auth/WindowsSQLiteCredentialStore.cs b/Kinvey.Net/Auth/WindowsSQLiteCredentialStore.cs index cfd7a516..152b1354 100644 --- a/Kinvey.Net/Auth/WindowsSQLiteCredentialStore.cs +++ b/Kinvey.Net/Auth/WindowsSQLiteCredentialStore.cs @@ -1,12 +1,11 @@ using System.Security.Cryptography; -using SQLite.Net.Interop; namespace Kinvey { public class WindowsSQLiteCredentialStore : SQLiteCredentialStore { - public WindowsSQLiteCredentialStore(ISQLitePlatform platform, string filepath) - : base(platform, filepath) + public WindowsSQLiteCredentialStore(string filepath) + : base(filepath) { } diff --git a/Kinvey.Net/Client/DotnetClientBuilder.cs b/Kinvey.Net/Client/DotnetClientBuilder.cs index 098565bf..c5de699d 100644 --- a/Kinvey.Net/Client/DotnetClientBuilder.cs +++ b/Kinvey.Net/Client/DotnetClientBuilder.cs @@ -1,4 +1,4 @@ -using SQLite.Net.Platform.Win32; + namespace Kinvey { @@ -7,7 +7,6 @@ public class DotnetClientBuilder : Client.Builder public DotnetClientBuilder(string appKey, string appSecret) : base(appKey, appSecret, Constants.DevicePlatform.NET) { - this.setOfflinePlatform(new SQLitePlatformWin32()); } } } diff --git a/Kinvey.Net/Kinvey.Net.csproj b/Kinvey.Net/Kinvey.Net.csproj index 163b6375..53f1ac90 100644 --- a/Kinvey.Net/Kinvey.Net.csproj +++ b/Kinvey.Net/Kinvey.Net.csproj @@ -44,15 +44,6 @@ ..\packages\System.Data.SQLite.Linq.1.0.105.0\lib\net46\System.Data.SQLite.Linq.dll - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll - diff --git a/Kinvey.Net/packages.config b/Kinvey.Net/packages.config index fec0e04d..9a47d9e6 100644 --- a/Kinvey.Net/packages.config +++ b/Kinvey.Net/packages.config @@ -2,8 +2,6 @@ - - diff --git a/Kinvey.Tests/ClientIntegrationTests.cs b/Kinvey.Tests/ClientIntegrationTests.cs index e896a401..8831cbb4 100644 --- a/Kinvey.Tests/ClientIntegrationTests.cs +++ b/Kinvey.Tests/ClientIntegrationTests.cs @@ -195,9 +195,8 @@ public async Task TestClientPingAsyncBad() [TestMethod] public async Task TestCustomEndpoint() { - // Arrange - Client.Builder builder = ClientBuilder.setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Arrange + Client.Builder builder = ClientBuilder.setFilePath(TestSetup.db_dir); if (MockData) builder.setBaseURL("http://localhost:8080"); @@ -230,10 +229,9 @@ public async Task TestCustomEndpoint() [TestMethod] public async Task TestCustomEndpointBad() { - // Arrange - Client.Builder builder = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Arrange + Client.Builder builder = ClientBuilder + .setFilePath(TestSetup.db_dir); if (MockData) { diff --git a/Kinvey.Tests/DataStoreCacheIntegrationTests.cs b/Kinvey.Tests/DataStoreCacheIntegrationTests.cs index 5305a149..ee75375b 100644 --- a/Kinvey.Tests/DataStoreCacheIntegrationTests.cs +++ b/Kinvey.Tests/DataStoreCacheIntegrationTests.cs @@ -34,8 +34,7 @@ public class DataStoreCacheIntegrationTests : BaseTestClass public void Setup() { Client.Builder builder = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + .setFilePath(TestSetup.db_dir); if (MockData) { diff --git a/Kinvey.Tests/DataStoreNetworkIntegrationTests.cs b/Kinvey.Tests/DataStoreNetworkIntegrationTests.cs index 62a04017..eec770a6 100644 --- a/Kinvey.Tests/DataStoreNetworkIntegrationTests.cs +++ b/Kinvey.Tests/DataStoreNetworkIntegrationTests.cs @@ -48,8 +48,7 @@ public override void Setup() System.IO.File.Delete(TestSetup.SQLiteOfflineStoreFilePath); System.IO.File.Delete(TestSetup.SQLiteCredentialStoreFilePath); - Client.Builder builder = ClientBuilder.setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = ClientBuilder.setFilePath(TestSetup.db_dir); if (MockData) { @@ -497,7 +496,6 @@ public async Task TestNetworkStoreFindAsyncBad() Client.Builder cb = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRC.Object)); Client c = cb.Build(); diff --git a/Kinvey.Tests/DataStoreSyncIntegrationTests.cs b/Kinvey.Tests/DataStoreSyncIntegrationTests.cs index b2095bd9..e606b424 100644 --- a/Kinvey.Tests/DataStoreSyncIntegrationTests.cs +++ b/Kinvey.Tests/DataStoreSyncIntegrationTests.cs @@ -39,7 +39,6 @@ public override void Setup() Client.Builder builder = ClientBuilder .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .setLogger(delegate (string msg) { System.Diagnostics.Debug.WriteLine(msg); }); if (MockData) diff --git a/Kinvey.Tests/DataStoreUnitTests.cs b/Kinvey.Tests/DataStoreUnitTests.cs index 4b39e979..6b1c73a3 100644 --- a/Kinvey.Tests/DataStoreUnitTests.cs +++ b/Kinvey.Tests/DataStoreUnitTests.cs @@ -21,7 +21,6 @@ public void TestSync() Client.Builder clientBuilder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRestClient.Object)); Client client = clientBuilder.Build(); diff --git a/Kinvey.Tests/Kinvey.Tests.csproj b/Kinvey.Tests/Kinvey.Tests.csproj index 74b12c9e..7f276f1a 100644 --- a/Kinvey.Tests/Kinvey.Tests.csproj +++ b/Kinvey.Tests/Kinvey.Tests.csproj @@ -16,5 +16,6 @@ + diff --git a/Kinvey.Tests/RealtimeIntegrationTests.cs b/Kinvey.Tests/RealtimeIntegrationTests.cs index 62d27dfa..f4989e00 100644 --- a/Kinvey.Tests/RealtimeIntegrationTests.cs +++ b/Kinvey.Tests/RealtimeIntegrationTests.cs @@ -31,9 +31,8 @@ public override void Setup() base.Setup(); string appKey = "kid_Zy0JOYPKkZ", appSecret = "d83de70e64d540e49acd6cfce31415df"; // UnitTestFramework - Client.Builder builder = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = ClientBuilder + .setFilePath(TestSetup.db_dir); if (MockData) builder.setBaseURL("http://localhost:8080"); diff --git a/Kinvey.Tests/Support Files/Address.cs b/Kinvey.Tests/Support Files/Address.cs index 9bf82b3a..04d7328c 100644 --- a/Kinvey.Tests/Support Files/Address.cs +++ b/Kinvey.Tests/Support Files/Address.cs @@ -1,36 +1,38 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; +using System.Runtime.Serialization; namespace Kinvey.Tests { [JsonObject(MemberSerialization.OptIn)] + [DataContract] public class Address : IPersistable { [JsonProperty("_id")] - [Preserve] + [DataMember(Name = "_id")] + [Preserve] [PrimaryKey, Column("_id")] public string ID { get; set; } [JsonProperty("_acl")] - [Preserve] + [DataMember(Name = "_acl")] + [Preserve] [Column("_acl")] - public AccessControlList ACL { get; set; } + public AccessControlList ACL { get; set; } [JsonProperty("_kmd")] - [Preserve] + [DataMember(Name = "_kmd")] + [Preserve] [Column("_kmd")] public KinveyMetaData KMD { get; set; } [JsonProperty] - public bool IsApartment { get; set; } + [DataMember] + public bool IsApartment { get; set; } [JsonProperty] - public string Street { get; set; } - - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } + [DataMember] + public string Street { get; set; } } } diff --git a/Kinvey.Tests/Support Files/AddressEntity.cs b/Kinvey.Tests/Support Files/AddressEntity.cs index e962be18..3fa69b05 100644 --- a/Kinvey.Tests/Support Files/AddressEntity.cs +++ b/Kinvey.Tests/Support Files/AddressEntity.cs @@ -1,15 +1,19 @@ using Newtonsoft.Json; using Kinvey; +using System.Runtime.Serialization; namespace Kinvey.Tests { [JsonObject(MemberSerialization.OptIn)] + [DataContract] public class AddressEntity : Entity { [JsonProperty] + [DataMember] public bool IsApartment { get; set; } [JsonProperty] - public string Street { get; set; } + [DataMember] + public string Street { get; set; } } } diff --git a/Kinvey.Tests/Support Files/Person.cs b/Kinvey.Tests/Support Files/Person.cs index affe72d0..5434065b 100644 --- a/Kinvey.Tests/Support Files/Person.cs +++ b/Kinvey.Tests/Support Files/Person.cs @@ -1,5 +1,5 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; namespace Kinvey.Tests @@ -33,10 +33,5 @@ public class Person : IPersistable [JsonProperty] public int Age { get; set; } - - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } } } diff --git a/Kinvey.Tests/Support Files/PersonEntity.cs b/Kinvey.Tests/Support Files/PersonEntity.cs index 84f57c18..17c9dc00 100644 --- a/Kinvey.Tests/Support Files/PersonEntity.cs +++ b/Kinvey.Tests/Support Files/PersonEntity.cs @@ -1,5 +1,5 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; namespace Kinvey.Tests diff --git a/Kinvey.Tests/UserIntegrationTests.cs b/Kinvey.Tests/UserIntegrationTests.cs index 35d26444..bec0e5aa 100644 --- a/Kinvey.Tests/UserIntegrationTests.cs +++ b/Kinvey.Tests/UserIntegrationTests.cs @@ -36,8 +36,7 @@ public override void Setup() base.Setup(); Client.Builder builder = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + .setFilePath(TestSetup.db_dir); if (MockData) builder.setBaseURL("http://localhost:8080"); if (MockData) builder.setMICHostName("http://localhost:8081"); @@ -747,8 +746,7 @@ public async Task TestUserInitFromCredential() { // Setup Client.Builder builder1 = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + .setFilePath(TestSetup.db_dir); if (MockData) builder1.setBaseURL("http://localhost:8080"); @@ -761,8 +759,7 @@ public async Task TestUserInitFromCredential() // Act Client.Builder builder2 = ClientBuilder - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + .setFilePath(TestSetup.db_dir); if (MockData) builder2.setBaseURL("http://localhost:8080"); diff --git a/Kinvey.Tests/UserUnitTests.cs b/Kinvey.Tests/UserUnitTests.cs index 2c869f6e..8c74f836 100644 --- a/Kinvey.Tests/UserUnitTests.cs +++ b/Kinvey.Tests/UserUnitTests.cs @@ -57,7 +57,6 @@ public async Task TestMICLoginAutomatedAuthFlowBad() Client.Builder cb = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRestClient.Object)); Client c = cb.Build(); diff --git a/Kinvey.sln b/Kinvey.sln index 899d65aa..33d28fdc 100644 --- a/Kinvey.sln +++ b/Kinvey.sln @@ -29,6 +29,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kinvey.Utils", "Kinvey.Util EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kinvey.Tests", "Kinvey.Tests\Kinvey.Tests.csproj", "{D91CC3CF-0D6D-496C-8136-AE3954D3C9C8}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sqlite-net", "sqlite-net", "{9B1D0AC8-EEE6-4210-9A63-80CABF1F757C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net", "sqlite-net\nuget\SQLite-net\SQLite-net.csproj", "{7F946494-8EE0-432B-8A87-98961143D5C1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-base", "sqlite-net\nuget\SQLite-net-base\SQLite-net-base.csproj", "{13986C0C-8A04-4F39-BB78-C1B71BDA4857}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-std", "sqlite-net\nuget\SQLite-net-std\SQLite-net-std.csproj", "{32711A14-971C-4A96-90B3-00A2D1E28E0D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite-net-sqlcipher", "sqlite-net\nuget\SQLite-net-sqlcipher\SQLite-net-sqlcipher.csproj", "{E27008B0-6880-4856-8C02-3DF7628A920C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -294,6 +304,78 @@ Global {D91CC3CF-0D6D-496C-8136-AE3954D3C9C8}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU {D91CC3CF-0D6D-496C-8136-AE3954D3C9C8}.AppStore|iPhone.ActiveCfg = Debug|Any CPU {D91CC3CF-0D6D-496C-8136-AE3954D3C9C8}.AppStore|iPhone.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|Any CPU.Build.0 = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Debug|iPhone.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|iPhone.ActiveCfg = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Release|iPhone.Build.0 = Release|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {7F946494-8EE0-432B-8A87-98961143D5C1}.AppStore|iPhone.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|Any CPU.Build.0 = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Debug|iPhone.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|iPhone.ActiveCfg = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Release|iPhone.Build.0 = Release|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {13986C0C-8A04-4F39-BB78-C1B71BDA4857}.AppStore|iPhone.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|Any CPU.Build.0 = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Debug|iPhone.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|iPhone.ActiveCfg = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Release|iPhone.Build.0 = Release|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {32711A14-971C-4A96-90B3-00A2D1E28E0D}.AppStore|iPhone.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|Any CPU.Build.0 = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Debug|iPhone.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|iPhone.ActiveCfg = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Release|iPhone.Build.0 = Release|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {E27008B0-6880-4856-8C02-3DF7628A920C}.AppStore|iPhone.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 @@ -322,5 +404,9 @@ Global $3.NewLineForClausesInQuery = False EndGlobalSection GlobalSection(NestedProjects) = preSolution + {7F946494-8EE0-432B-8A87-98961143D5C1} = {9B1D0AC8-EEE6-4210-9A63-80CABF1F757C} + {13986C0C-8A04-4F39-BB78-C1B71BDA4857} = {9B1D0AC8-EEE6-4210-9A63-80CABF1F757C} + {32711A14-971C-4A96-90B3-00A2D1E28E0D} = {9B1D0AC8-EEE6-4210-9A63-80CABF1F757C} + {E27008B0-6880-4856-8C02-3DF7628A920C} = {9B1D0AC8-EEE6-4210-9A63-80CABF1F757C} EndGlobalSection EndGlobal diff --git a/Kinvey/Kinvey.csproj b/Kinvey/Kinvey.csproj index 39789650..1df815b9 100644 --- a/Kinvey/Kinvey.csproj +++ b/Kinvey/Kinvey.csproj @@ -8,13 +8,13 @@ - - - + + + diff --git a/TestFramework/TestSupportFiles/Address.cs b/TestFramework/TestSupportFiles/Address.cs index b2335159..e779b70d 100644 --- a/TestFramework/TestSupportFiles/Address.cs +++ b/TestFramework/TestSupportFiles/Address.cs @@ -1,36 +1,41 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; +using System.Runtime.Serialization; namespace TestFramework { [JsonObject(MemberSerialization.OptIn)] + [DataContract] public class Address : IPersistable { [JsonProperty("_id")] - [Preserve] - [PrimaryKey, Column("_id")] + [DataMember(Name = "_id")] + [Kinvey.Preserve] + [SQLite.Preserve] + [PrimaryKey, Column("_id")] public string ID { get; set; } [JsonProperty("_acl")] - [Preserve] - [Column("_acl")] + [DataMember(Name = "_acl")] + [Kinvey.Preserve] + [SQLite.Preserve] + [Column("_acl")] public AccessControlList ACL { get; set; } [JsonProperty("_kmd")] - [Preserve] - [Column("_kmd")] + [DataMember(Name = "_kmd")] + [Kinvey.Preserve] + [SQLite.Preserve] + [Column("_kmd")] public KinveyMetaData KMD { get; set; } [JsonProperty] - public bool IsApartment { get; set; } + [DataMember] + public bool IsApartment { get; set; } [JsonProperty] - public string Street { get; set; } - - public string Serialize() - { - return JsonConvert.SerializeObject(this); - } + [DataMember] + public string Street { get; set; } } } diff --git a/TestFramework/TestSupportFiles/AddressEntity.cs b/TestFramework/TestSupportFiles/AddressEntity.cs index 4e89b0e3..ccecf81c 100644 --- a/TestFramework/TestSupportFiles/AddressEntity.cs +++ b/TestFramework/TestSupportFiles/AddressEntity.cs @@ -1,15 +1,19 @@ using Newtonsoft.Json; using Kinvey; +using System.Runtime.Serialization; namespace TestFramework { [JsonObject(MemberSerialization.OptIn)] + [DataContract] public class AddressEntity : Entity { [JsonProperty] + [DataMember] public bool IsApartment { get; set; } [JsonProperty] - public string Street { get; set; } + [DataMember] + public string Street { get; set; } } } diff --git a/TestFramework/TestSupportFiles/Person.cs b/TestFramework/TestSupportFiles/Person.cs index f3282811..4f1f5b41 100644 --- a/TestFramework/TestSupportFiles/Person.cs +++ b/TestFramework/TestSupportFiles/Person.cs @@ -1,5 +1,5 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; namespace TestFramework @@ -8,18 +8,21 @@ namespace TestFramework public class Person : IPersistable { [JsonProperty("_id")] - [Preserve] - [PrimaryKey, Column("_id")] + [Kinvey.Preserve] + [SQLite.Preserve] + [PrimaryKey, Column("_id")] public string ID { get; set; } [JsonProperty("_acl")] - [Preserve] - [Column("_acl")] + [Kinvey.Preserve] + [SQLite.Preserve] + [Column("_acl")] public AccessControlList ACL { get; set; } [JsonProperty("_kmd")] - [Preserve] - [Column("_kmd")] + [Kinvey.Preserve] + [SQLite.Preserve] + [Column("_kmd")] public KinveyMetaData KMD { get; set; } [JsonProperty] diff --git a/TestFramework/TestSupportFiles/PersonEntity.cs b/TestFramework/TestSupportFiles/PersonEntity.cs index 54464616..badb49c1 100644 --- a/TestFramework/TestSupportFiles/PersonEntity.cs +++ b/TestFramework/TestSupportFiles/PersonEntity.cs @@ -1,5 +1,5 @@ using Newtonsoft.Json; -using SQLite.Net.Attributes; +using SQLite; using Kinvey; namespace TestFramework diff --git a/TestFramework/TestSupportFiles/kinveyOffline.sqlite-shm b/TestFramework/TestSupportFiles/kinveyOffline.sqlite-shm new file mode 100644 index 00000000..a1913d25 Binary files /dev/null and b/TestFramework/TestSupportFiles/kinveyOffline.sqlite-shm differ diff --git a/TestFramework/TestSupportFiles/kinveyOffline.sqlite-wal b/TestFramework/TestSupportFiles/kinveyOffline.sqlite-wal new file mode 100644 index 00000000..dc1d5dd0 Binary files /dev/null and b/TestFramework/TestSupportFiles/kinveyOffline.sqlite-wal differ diff --git a/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-shm b/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-shm new file mode 100644 index 00000000..cdf9ebc8 Binary files /dev/null and b/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-shm differ diff --git a/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-wal b/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-wal new file mode 100644 index 00000000..b23d53ce Binary files /dev/null and b/TestFramework/TestSupportFiles/kinvey_tokens.sqlite-wal differ diff --git a/TestFramework/Tests.Integration/Tests.Integration.csproj b/TestFramework/Tests.Integration/Tests.Integration.csproj index 6bf84d72..1760304b 100644 --- a/TestFramework/Tests.Integration/Tests.Integration.csproj +++ b/TestFramework/Tests.Integration/Tests.Integration.csproj @@ -79,15 +79,6 @@ ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - - ..\..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll - - - ..\..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll - ..\..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll @@ -105,9 +96,6 @@ ..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - ..\..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll - ..\..\packages\System.IO.4.1.0\lib\net462\System.IO.dll @@ -140,12 +128,32 @@ + + + ..\..\packages\SQLitePCLRaw.core.1.1.11\lib\net45\SQLitePCLRaw.core.dll + + + ..\..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.11\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll + + + ..\..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_green.dll + + + ..\..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_v2.dll + {BCF7F3A3-8069-49CE-B9E8-3F4D9A5FF234} Kinvey + + {32711A14-971C-4A96-90B3-00A2D1E28E0D} + SQLite-net-std + + + + \ No newline at end of file diff --git a/TestFramework/Tests.Integration/Tests/ClientIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/ClientIntegrationTests.cs index 44ece522..3a7eb056 100644 --- a/TestFramework/Tests.Integration/Tests/ClientIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/ClientIntegrationTests.cs @@ -70,8 +70,7 @@ public void TestClientBuilderSetValues() Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret); // Act - builder.setFilePath("") - .setLogger(Console.WriteLine); + builder.setLogger(Console.WriteLine); // Assert Client client = builder.Build(); @@ -183,10 +182,9 @@ public async Task TestClientPingAsyncBad() [Test] public async Task TestCustomEndpoint() { - // Arrange - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Arrange + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); builder.Build(); @@ -217,10 +215,9 @@ public async Task TestCustomEndpoint() [Test] public async Task TestCustomEndpointBad() { - // Arrange - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Arrange + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); builder.Build(); diff --git a/TestFramework/Tests.Integration/Tests/DataStoreCacheIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/DataStoreCacheIntegrationTests.cs index 92354da8..99c7f0e8 100644 --- a/TestFramework/Tests.Integration/Tests/DataStoreCacheIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/DataStoreCacheIntegrationTests.cs @@ -33,9 +33,8 @@ public class DataStoreCacheIntegrationTests [SetUp] public void Setup() { - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); kinveyClient = builder.Build(); } diff --git a/TestFramework/Tests.Integration/Tests/DataStoreNetworkIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/DataStoreNetworkIntegrationTests.cs index 45840de3..46811dd2 100644 --- a/TestFramework/Tests.Integration/Tests/DataStoreNetworkIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/DataStoreNetworkIntegrationTests.cs @@ -36,9 +36,8 @@ public class DataStoreNetworkIntegrationTests [SetUp] public void Setup() { - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); kinveyClient = builder.Build(); } @@ -142,7 +141,6 @@ public async Task TestNetworkStoreFindAsyncBad() Client.Builder cb = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRC.Object)); Client c = cb.Build(); diff --git a/TestFramework/Tests.Integration/Tests/DataStoreSyncIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/DataStoreSyncIntegrationTests.cs index 95f2b0da..3a4a2823 100644 --- a/TestFramework/Tests.Integration/Tests/DataStoreSyncIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/DataStoreSyncIntegrationTests.cs @@ -34,9 +34,8 @@ public class DataStoreSyncIntegrationTests [SetUp] public void Setup() { - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); kinveyClient = builder.Build(); } diff --git a/TestFramework/Tests.Integration/Tests/RealtimeIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/RealtimeIntegrationTests.cs index e13a714f..c89f6b2b 100644 --- a/TestFramework/Tests.Integration/Tests/RealtimeIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/RealtimeIntegrationTests.cs @@ -29,9 +29,8 @@ public class RealtimeIntegrationTests public void Setup() { string appKey = "kid_Zy0JOYPKkZ", appSecret = "d83de70e64d540e49acd6cfce31415df"; // UnitTestFramework - Client.Builder builder = new Client.Builder(appKey, appSecret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = new Client.Builder(appKey, appSecret) + .setFilePath(TestSetup.db_dir); kinveyClient = builder.Build(); } diff --git a/TestFramework/Tests.Integration/Tests/UserIntegrationTests.cs b/TestFramework/Tests.Integration/Tests/UserIntegrationTests.cs index 9c9babd8..32233373 100644 --- a/TestFramework/Tests.Integration/Tests/UserIntegrationTests.cs +++ b/TestFramework/Tests.Integration/Tests/UserIntegrationTests.cs @@ -33,9 +33,8 @@ public class UserIntegrationTests [SetUp] public void Setup() { - Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); kinveyClient = builder.Build(); } @@ -825,20 +824,18 @@ public async Task TestUserKMDPasswordReset() [Test] public async Task TestUserInitFromCredential() { - // Setup - Client.Builder builder1 = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Setup + Client.Builder builder1 = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); Client kinveyClient1 = builder1.Build(); // Arrange User activeUser = await User.LoginAsync(TestSetup.user, TestSetup.pass, kinveyClient1); - // Act - Client.Builder builder2 = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) - .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()); + // Act + Client.Builder builder2 = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) + .setFilePath(TestSetup.db_dir); Client kinveyClient2 = builder2.Build(); diff --git a/TestFramework/Tests.Integration/packages.config b/TestFramework/Tests.Integration/packages.config index 25cc340c..a36be85a 100644 --- a/TestFramework/Tests.Integration/packages.config +++ b/TestFramework/Tests.Integration/packages.config @@ -8,9 +8,12 @@ - - - + + + + + + diff --git a/TestFramework/Tests.Unit/Tests.Unit.csproj b/TestFramework/Tests.Unit/Tests.Unit.csproj index a32a80bb..376ac014 100644 --- a/TestFramework/Tests.Unit/Tests.Unit.csproj +++ b/TestFramework/Tests.Unit/Tests.Unit.csproj @@ -55,21 +55,9 @@ ..\..\packages\Moq.4.9.0\lib\net45\Moq.dll - - ..\..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll - - - ..\..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll - ..\..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - ..\..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll - ..\..\packages\System.IO.4.1.0\lib\net462\System.IO.dll @@ -98,6 +86,19 @@ ..\..\packages\Pubnub.4.0.21\lib\net461\Pubnub.dll + + ..\..\packages\SQLitePCLRaw.core.1.1.11\lib\net45\SQLitePCLRaw.core.dll + + + ..\..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.11\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll + + + ..\..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_green.dll + + + ..\..\packages\SQLitePCLRaw.bundle_green.1.1.11\lib\net45\SQLitePCLRaw.batteries_v2.dll + + @@ -134,6 +135,10 @@ {BCF7F3A3-8069-49CE-B9E8-3F4D9A5FF234} Kinvey + + {32711A14-971C-4A96-90B3-00A2D1E28E0D} + SQLite-net-std + @@ -145,4 +150,7 @@ + + + \ No newline at end of file diff --git a/TestFramework/Tests.Unit/Tests/ClientUnitTests.cs b/TestFramework/Tests.Unit/Tests/ClientUnitTests.cs index 6ab9826a..7f7ddf62 100644 --- a/TestFramework/Tests.Unit/Tests/ClientUnitTests.cs +++ b/TestFramework/Tests.Unit/Tests/ClientUnitTests.cs @@ -81,8 +81,7 @@ public void TestClientBuilderSetValues() Client.Builder builder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret); // Act - builder.setFilePath("") - .setLogger(delegate (string msg) { Console.WriteLine(msg); }); + builder.setLogger(delegate (string msg) { Console.WriteLine(msg); }); // Assert Client client = builder.Build(); diff --git a/TestFramework/Tests.Unit/Tests/DataStoreUnitTests.cs b/TestFramework/Tests.Unit/Tests/DataStoreUnitTests.cs index 9f99c8d9..59cb913e 100644 --- a/TestFramework/Tests.Unit/Tests/DataStoreUnitTests.cs +++ b/TestFramework/Tests.Unit/Tests/DataStoreUnitTests.cs @@ -21,7 +21,6 @@ public void TestSync() Client.Builder clientBuilder = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRestClient.Object)); Client client = clientBuilder.Build(); diff --git a/TestFramework/Tests.Unit/Tests/UserUnitTests.cs b/TestFramework/Tests.Unit/Tests/UserUnitTests.cs index 1a71a729..1546ca31 100644 --- a/TestFramework/Tests.Unit/Tests/UserUnitTests.cs +++ b/TestFramework/Tests.Unit/Tests/UserUnitTests.cs @@ -90,7 +90,6 @@ public async Task TestMICLoginAutomatedAuthFlowBad() Client.Builder cb = new Client.Builder(TestSetup.app_key, TestSetup.app_secret) .setFilePath(TestSetup.db_dir) - .setOfflinePlatform(new SQLite.Net.Platform.Generic.SQLitePlatformGeneric()) .SetRestClient(new HttpClient(moqRestClient.Object)); Client c = cb.Build(); diff --git a/TestFramework/Tests.Unit/packages.config b/TestFramework/Tests.Unit/packages.config index 25cc340c..a36be85a 100644 --- a/TestFramework/Tests.Unit/packages.config +++ b/TestFramework/Tests.Unit/packages.config @@ -8,9 +8,12 @@ - - - + + + + + + diff --git a/sqlite-net b/sqlite-net new file mode 160000 index 00000000..01d42ede --- /dev/null +++ b/sqlite-net @@ -0,0 +1 @@ +Subproject commit 01d42ede5f0196e3fc2b149f7cd5726627ad2cb4 diff --git a/test-ios-app/AppDelegate.cs b/test-ios-app/AppDelegate.cs index 039f0c6c..1ad9bea0 100644 --- a/test-ios-app/AppDelegate.cs +++ b/test-ios-app/AppDelegate.cs @@ -3,7 +3,6 @@ using Kinvey; using KinveyXamariniOS; -using SQLite.Net.Platform.XamarinIOS; using System.Threading.Tasks; using System; using System.Collections.Generic; @@ -50,7 +49,6 @@ public void BuildClient() Client.Builder cb = new Client.Builder(appKey, appSecret) .setFilePath(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].ToString()) - .setOfflinePlatform(new SQLitePlatformIOS()) //.setCredentdialStore(new IOSNativeCredentialStore()) //.SetSSOGroupKey("KinveyOrg") .setLogger(delegate (string msg) { Console.WriteLine(msg); }); diff --git a/test-ios-app/packages.config b/test-ios-app/packages.config index cff39289..51e6b956 100644 --- a/test-ios-app/packages.config +++ b/test-ios-app/packages.config @@ -2,7 +2,4 @@ - - - \ No newline at end of file diff --git a/test-ios-app/test-ios-app.csproj b/test-ios-app/test-ios-app.csproj index 17aa3323..381dd2d2 100644 --- a/test-ios-app/test-ios-app.csproj +++ b/test-ios-app/test-ios-app.csproj @@ -75,15 +75,6 @@ ..\packages\Remotion.Linq.2.0.1\lib\portable-net45+win+wpa81+wp80\Remotion.Linq.dll - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\Xamarin.iOS10\SQLite.Net.Platform.XamarinIOS.Unified.dll - - - ..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll diff --git a/testdroidapp/MainActivity.cs b/testdroidapp/MainActivity.cs index ad9ef016..64397c15 100644 --- a/testdroidapp/MainActivity.cs +++ b/testdroidapp/MainActivity.cs @@ -3,7 +3,6 @@ using Android.OS; using System; using System.Threading.Tasks; -using SQLite.Net.Platform.XamarinAndroid; using Kinvey; namespace testdroidapp @@ -39,7 +38,6 @@ protected override async void OnCreate(Bundle savedInstanceState) Client.Builder builder = new Client.Builder("kid_b1d6IY_x7l", "079412ee99f4485d85e6e362fb987de8") //Client.Builder builder = new Client.Builder ("kid_ZkPDb_34T", "c3752d5079f34353ab89d07229efaf63") // MIC-SAML-TEST .setFilePath(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)) - .setOfflinePlatform(new SQLitePlatformAndroid()) .setCredentialStore(new AndroidNativeCredentialStore(this.ApplicationContext)) .SetSSOGroupKey("com.kinvey") .setLogger(delegate (string msg) { Console.WriteLine(msg); }); diff --git a/testdroidapp/Resources/Resource.designer.cs b/testdroidapp/Resources/Resource.designer.cs index b7037c58..efa30faf 100644 --- a/testdroidapp/Resources/Resource.designer.cs +++ b/testdroidapp/Resources/Resource.designer.cs @@ -26,8 +26,6 @@ static Resource() public static void UpdateIdValues() { - global::SQLite.Net.Platform.XamarinAndroid.Resource.String.ApplicationName = global::testdroidapp.Resource.String.ApplicationName; - global::SQLite.Net.Platform.XamarinAndroid.Resource.String.Hello = global::testdroidapp.Resource.String.Hello; } public partial class Attribute @@ -114,16 +112,10 @@ public partial class String { // aapt resource value: 0x7f050001 - public const int ApplicationName = 2131034113; + public const int app_name = 2131034113; // aapt resource value: 0x7f050000 - public const int Hello = 2131034112; - - // aapt resource value: 0x7f050003 - public const int app_name = 2131034115; - - // aapt resource value: 0x7f050002 - public const int hello = 2131034114; + public const int hello = 2131034112; static String() { diff --git a/testdroidapp/packages.config b/testdroidapp/packages.config index 77c9e8c5..88f2eccc 100644 --- a/testdroidapp/packages.config +++ b/testdroidapp/packages.config @@ -1,7 +1,4 @@  - - - - + \ No newline at end of file diff --git a/testdroidapp/testdroidapp.csproj b/testdroidapp/testdroidapp.csproj index ca078ccb..ff2c3261 100644 --- a/testdroidapp/testdroidapp.csproj +++ b/testdroidapp/testdroidapp.csproj @@ -8,14 +8,14 @@ Library testdroidapp testdroidapp - v9.0 + v5.1 True Resources\Resource.designer.cs Resource Properties\AndroidManifest.xml Resources Assets - true + false true @@ -42,13 +42,7 @@ - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net.Platform.XamarinAndroid.2.5.1\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll @@ -84,14 +78,14 @@ {444456B1-5B55-48D6-9637-00ADCA92B7C9} Kinvey-Utils - - {77977557-862E-4A14-A5D7-0096023BA682} - Kinvey-Xamarin-Android - {6644D98D-026B-48E9-95A3-61C4D98D82E7} Kinvey.Core + + {77977557-862E-4A14-A5D7-0096023BA682} + Kinvey-Xamarin-Android + \ No newline at end of file diff --git a/testdroidapp2/MainActivity.cs b/testdroidapp2/MainActivity.cs index ff2c3f45..37e4c917 100644 --- a/testdroidapp2/MainActivity.cs +++ b/testdroidapp2/MainActivity.cs @@ -3,7 +3,6 @@ using Android.OS; using System; using System.Threading.Tasks; -using SQLite.Net.Platform.XamarinAndroid; using Kinvey; namespace testdroidapp2 @@ -39,7 +38,6 @@ protected override async void OnCreate(Bundle savedInstanceState) Client.Builder builder = new Client.Builder("kid_b1d6IY_x7l", "079412ee99f4485d85e6e362fb987de8") //Client.Builder builder = new Client.Builder ("kid_ZkPDb_34T", "c3752d5079f34353ab89d07229efaf63") // MIC-SAML-TEST .setFilePath(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)) - .setOfflinePlatform(new SQLitePlatformAndroid()) .setCredentialStore(new AndroidNativeCredentialStore(this.ApplicationContext)) .SetSSOGroupKey("com.kinvey") .setLogger(delegate (string msg) { Console.WriteLine(msg); }); diff --git a/testdroidapp2/Resources/Resource.designer.cs b/testdroidapp2/Resources/Resource.designer.cs index 976d06a9..bc57821f 100644 --- a/testdroidapp2/Resources/Resource.designer.cs +++ b/testdroidapp2/Resources/Resource.designer.cs @@ -26,8 +26,6 @@ static Resource() public static void UpdateIdValues() { - global::SQLite.Net.Platform.XamarinAndroid.Resource.String.ApplicationName = global::testdroidapp2.Resource.String.ApplicationName; - global::SQLite.Net.Platform.XamarinAndroid.Resource.String.Hello = global::testdroidapp2.Resource.String.Hello; } public partial class Attribute @@ -114,16 +112,10 @@ public partial class String { // aapt resource value: 0x7f050001 - public const int ApplicationName = 2131034113; + public const int app_name = 2131034113; // aapt resource value: 0x7f050000 - public const int Hello = 2131034112; - - // aapt resource value: 0x7f050003 - public const int app_name = 2131034115; - - // aapt resource value: 0x7f050002 - public const int hello = 2131034114; + public const int hello = 2131034112; static String() { diff --git a/testdroidapp2/packages.config b/testdroidapp2/packages.config index bc324399..c509390b 100644 --- a/testdroidapp2/packages.config +++ b/testdroidapp2/packages.config @@ -1,6 +1,4 @@  - - \ No newline at end of file diff --git a/testdroidapp2/testdroidapp2.csproj b/testdroidapp2/testdroidapp2.csproj index ac78c6d2..4e1730e1 100644 --- a/testdroidapp2/testdroidapp2.csproj +++ b/testdroidapp2/testdroidapp2.csproj @@ -8,14 +8,14 @@ Library testdroidapp2 testdroidapp2 - v9.0 + v5.1 True Resources\Resource.designer.cs Resource Properties\AndroidManifest.xml Resources Assets - true + false true @@ -28,6 +28,7 @@ false None arm64-v8a;armeabi;armeabi-v7a;x86 + true true @@ -42,12 +43,6 @@ - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll - ..\packages\Newtonsoft.Json.11.0.2\lib\netstandard2.0\Newtonsoft.Json.dll diff --git a/testiosapp2/AppDelegate.cs b/testiosapp2/AppDelegate.cs index 0715dc32..39d314a9 100644 --- a/testiosapp2/AppDelegate.cs +++ b/testiosapp2/AppDelegate.cs @@ -3,7 +3,6 @@ using Kinvey; using KinveyXamariniOS; -using SQLite.Net.Platform.XamarinIOS; using System.Threading.Tasks; using System; using System.Collections.Generic; @@ -49,7 +48,6 @@ public void BuildClient() Client.Builder cb = new Client.Builder(appKey, appSecret) .setFilePath(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].ToString()) - .setOfflinePlatform(new SQLitePlatformIOS()) .setCredentialStore(new IOSNativeCredentialStore()) .SetSSOGroupKey("KinveyOrg") //.setBaseURL("https://alm-kcs.ngrok.io") diff --git a/testiosapp2/packages.config b/testiosapp2/packages.config index 0a883c63..b78d11d5 100644 --- a/testiosapp2/packages.config +++ b/testiosapp2/packages.config @@ -6,8 +6,6 @@ - - diff --git a/testiosapp2/testiosapp2.csproj b/testiosapp2/testiosapp2.csproj index 0a201270..9cd39513 100644 --- a/testiosapp2/testiosapp2.csproj +++ b/testiosapp2/testiosapp2.csproj @@ -83,12 +83,6 @@ - - ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll - - - ..\packages\SQLite.Net-PCL.3.1.1\lib\Xamarin.iOS10\SQLite.Net.Platform.XamarinIOS.Unified.dll - ..\packages\Remotion.Linq.2.0.1\lib\portable-net45+win+wpa81+wp80\Remotion.Linq.dll