public async Task TestTimeSpan()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     await TestAsyncDateTime(db);
 }
Example #2
0
        public Database(ISQLitePlatform platform, string databasePath)
        {
            _connectionParameters = new SQLiteConnectionString(databasePath, false);
            _sqliteConnectionPool = new SQLiteConnectionPool(platform);

            _dbConnection = new SQLiteAsyncConnection(() => _sqliteConnectionPool.GetConnection(_connectionParameters));
        }
 public void AsyncAsTicks ()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     TestAsyncDateTimeOffset (db);
 }
Example #4
0
        internal MbTilesCache(SQLiteConnectionString connectionString, ITileSchema schema = null, MbTilesType type = MbTilesType.None)
        {
            if (_connectionPool == null)
            {
                throw new InvalidOperationException("You must assign a platform prior to using MbTilesCache by calling MbTilesTileSource.SetPlatform()");
            }

            _connectionString = connectionString;
            var connection = _connectionPool.GetConnection(connectionString);

            using (connection.Lock())
            {
                _type = type == MbTilesType.None ? ReadType(connection) : type;

                if (schema == null)
                {
                    // Format (if defined)
                    _format = ReadFormat(connection);

                    // Extent
                    _extent = ReadExtent(connection);


                    if (HasMapTable(connection))
                    {
                        // it is possible to override the schema by definining it in a 'map' table.
                        // This method depends on reading tiles from an 'images' table, which
                        // is not part of the MBTiles spec

                        // Declared zoom levels
                        var declaredZoomLevels = ReadZoomLevels(connection, out _tileRange);

                        // Create schema
                        _schema = new GlobalMercator(_format.ToString(), declaredZoomLevels);
                    }
                    else
                    {
                        // this is actually the most regular case:
                        _schema = new GlobalSphericalMercator();
                    }
                }
                else
                {
                    _schema = schema;
                }
            }
        }
        public async Task TestTimeSpan()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformTest());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            await TestAsyncDateTime(db);
        }
Example #6
0
        public void AsyncAsTicks()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformWin32());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            TestAsyncDateTime(db);
        }
Example #7
0
        public async Task AsyncAsString()
        {
            var sqLiteConnectionPool   = new SQLiteConnectionPool(new SQLitePlatformTest());
            var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));

            await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks);
        }
Example #8
0
        public async Task UnicodePathsAsync()
        {
            string path = Path.GetTempFileName() + UnicodeText;

            var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(new SQLiteConnectionString(path, true)));
            await db.CreateTableAsync <OrderLine>();

            Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
        }
Example #9
0
        public void UnicodePathsAsync()
        {
            string path = Path.GetTempFileName() + UnicodeText;

            var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformWin32());
            var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(new SQLiteConnectionString(path, true)));
            db.CreateTableAsync<OrderLine>().Wait();

            Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
        }
Example #10
0
        public SqliteEventStore(ISQLitePlatform sqLitePlatform, string databasePath, GetUtcNow getUtcNow = null)
        {
            Ensure.That(sqLitePlatform, "sqLitePlatform").IsNotNull();
            Ensure.That(databasePath, "databasePath").IsNotNull();

            _getUtcNow      = getUtcNow ?? SystemClock.GetUtcNow;
            _connectionPool = new SQLiteConnectionPool(sqLitePlatform);
            var connectionString = new SQLiteConnectionString(databasePath, false);

            _getConnection = () => _connectionPool.GetConnection(connectionString);
        }
Example #11
0
        private SQLiteAsyncConnection CreateSqliteAsyncConnection()
        {
            var sqliteFilename = "MyDatabase.db3";
            var libraryPath    = _configuration.DbPath;

//#if __ANDROID__
//				string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ;
//#else
//            // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
//            // (they don't want non-user-generated data in Documents)
//            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
//            string libraryPath = Path.Combine(documentsPath, "../Library/");
//#endif
            var sqLitePath = Path.Combine(libraryPath, sqliteFilename);

            var connectionString     = new SQLiteConnectionString(sqLitePath, true);
            var sqLiteConnectionPool = new SQLiteConnectionPool(_configuration.SQLitePlatform);

            Debug.WriteLine(string.Format("sqlitePath: {0}", sqLitePath));

            return(new SQLiteAsyncConnection(() =>
                                             sqLiteConnectionPool.GetConnection(connectionString)));
        }
Example #12
0
 private SQLiteAsyncConnection GetConnection(ref string path)
 {
     path = _path;
     return(new SQLiteAsyncConnection(() => _sqliteConnectionPool.GetConnection(_connectionParameters)));
 }
 public async Task AsyncAsString()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks);
 }
Example #14
0
 public virtual Database.IAsyncConnection GetAsyncDBConnection()
 {
     return(new Database.AsyncConnection(() => _connectionPool.GetConnection(_connectionString)));
 }