diff --git a/src/ImageProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor/Properties/AssemblyInfo.cs index 49264fada..d25387498 100644 --- a/src/ImageProcessor/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ using System.Security; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] +[assembly: AssemblyVersion("1.7.0.0")] +[assembly: AssemblyFileVersion("1.7.0.0")] diff --git a/src/Nuget/ImageProcessor.1.3.0.0.nupkg b/src/Nuget/ImageProcessor.1.3.0.0.nupkg deleted file mode 100644 index ea6252a56..000000000 Binary files a/src/Nuget/ImageProcessor.1.3.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.1.4.0.0.nupkg b/src/Nuget/ImageProcessor.1.4.0.0.nupkg deleted file mode 100644 index e3dfdce91..000000000 Binary files a/src/Nuget/ImageProcessor.1.4.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.1.4.1.0.nupkg b/src/Nuget/ImageProcessor.1.4.1.0.nupkg deleted file mode 100644 index 06ae2f3d5..000000000 Binary files a/src/Nuget/ImageProcessor.1.4.1.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.1.4.2.0.nupkg b/src/Nuget/ImageProcessor.1.4.2.0.nupkg deleted file mode 100644 index f4d8acee9..000000000 Binary files a/src/Nuget/ImageProcessor.1.4.2.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.1.5.0.0.nupkg b/src/Nuget/ImageProcessor.1.5.0.0.nupkg deleted file mode 100644 index ef69659f5..000000000 Binary files a/src/Nuget/ImageProcessor.1.5.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.1.6.0.0.nupkg b/src/Nuget/ImageProcessor.1.6.0.0.nupkg deleted file mode 100644 index b2a2773ff..000000000 Binary files a/src/Nuget/ImageProcessor.1.6.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.1.3.0.0.nupkg b/src/Nuget/ImageProcessor.Web.1.3.0.0.nupkg deleted file mode 100644 index 62f1a7034..000000000 Binary files a/src/Nuget/ImageProcessor.Web.1.3.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.0.0.0.nupkg b/src/Nuget/ImageProcessor.Web.2.0.0.0.nupkg deleted file mode 100644 index 2ccc1e324..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.0.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.0.1.0.nupkg b/src/Nuget/ImageProcessor.Web.2.0.1.0.nupkg deleted file mode 100644 index cbd19db4a..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.0.1.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.0.0.nupkg b/src/Nuget/ImageProcessor.Web.2.1.0.0.nupkg deleted file mode 100644 index b960407ee..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.1.0.0.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.0.1.nupkg b/src/Nuget/ImageProcessor.Web.2.1.0.1.nupkg deleted file mode 100644 index ea29c4557..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.1.0.1.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.0.2.nupkg b/src/Nuget/ImageProcessor.Web.2.1.0.2.nupkg deleted file mode 100644 index f64d45844..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.1.0.2.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.0.3.nupkg b/src/Nuget/ImageProcessor.Web.2.1.0.3.nupkg deleted file mode 100644 index dc1716f01..000000000 Binary files a/src/Nuget/ImageProcessor.Web.2.1.0.3.nupkg and /dev/null differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.0.4.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.1.0.4.nupkg.REMOVED.git-id deleted file mode 100644 index 0ab6ebd84..000000000 --- a/src/Nuget/ImageProcessor.Web.2.1.0.4.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -eaff612b7db9e40f185c91161fd9c977faec69bb \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.1.1.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.1.1.0.nupkg.REMOVED.git-id deleted file mode 100644 index 14f2e3816..000000000 --- a/src/Nuget/ImageProcessor.Web.2.1.1.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -2af35ccdf0476cbe432b2440be45ffd0f6c414f4 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id deleted file mode 100644 index fd25a7d25..000000000 --- a/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -1ac41e14e3ae5f8ac9b06bcfbbacc6c4a9841863 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.0.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.0.0.nupkg.REMOVED.git-id deleted file mode 100644 index 6a7fcd2da..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.0.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -13403db94dce99fd4e73114b3334d4ef0c2b4ae5 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.0.1.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.0.1.nupkg.REMOVED.git-id deleted file mode 100644 index cf985cfa6..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.0.1.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -8a3fd4491298fec4626034f03e534caac7f22941 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.0.1.nuspec b/src/Nuget/ImageProcessor.Web.2.2.0.1.nuspec deleted file mode 100644 index a315efbfb..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.0.1.nuspec +++ /dev/null @@ -1,43 +0,0 @@ - - - - ImageProcessor.Web - 2.2.0.1 - ImageProcessor.Web - James South - James South - http://jimbobsquarepants.github.com/ImageProcessor/ - false - ImageProcessor.Web adds a configurable HttpModule to your website which allows on-the-fly processing of image files. The module also comes with a file and browser based cache that can handle up to 12,960,000 images increasing your processing output and saving precious server memory. - -Methods include; Resize, Rotate, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, and Transparency. - -This package also requires Microsoft.Bcl.Async -pre on .NET 4.0 which will be added in the background on install if applicable. - -If you use ImageProcessor please get in touch via my twitter @james_m_south - - -Feedback is always welcome. - An extension to ImageProcessor that allows on-the-fly processing of image files in an ASP.NET website - Fixed cache bug which caused unneccessary processing of images. - -If upgrading from < 2.2.0.0 You will have to delete your cache if upgrading to this version as the database differs. - James South - en-GB - Image, Imaging, ASP, Performance, Processing, HttpModule, Cache, Resize, Rotate, Flip, Crop, Filter, Effects, Quality, Watermark, Alpha, Vignette, Saturation, Brightness, Contrast, Gif, Jpeg, Bitmap, Png, Fluent - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.1.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.1.0.nupkg.REMOVED.git-id deleted file mode 100644 index 70022fab7..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.1.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -46b009d93ab9f1ea75f1ea1efb0073b3d369d3e5 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.2.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.2.0.nupkg.REMOVED.git-id deleted file mode 100644 index 64982e401..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.2.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -50dc5dc47c964ccc80bb8abb22650a579ae796c3 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.3.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.3.0.nupkg.REMOVED.git-id deleted file mode 100644 index f88996db3..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.3.0.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -9142f8cdad57d5c52d8721112c18a8d26c6f9817 \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.3.1.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.3.1.nupkg.REMOVED.git-id deleted file mode 100644 index 49e39b863..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.3.1.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -24114542de37d7b4463b56749e64e34b0d43a9cc \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.2.2.3.2.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.2.3.2.nupkg.REMOVED.git-id deleted file mode 100644 index 708746904..000000000 --- a/src/Nuget/ImageProcessor.Web.2.2.3.2.nupkg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -3de0aa82f042cfdda2764554fb34e686b401df85 \ No newline at end of file diff --git a/src/Nuget/imageprocessor.128.png b/src/Nuget/imageprocessor.128.png index a2637e48b..db4f3d565 100644 Binary files a/src/Nuget/imageprocessor.128.png and b/src/Nuget/imageprocessor.128.png differ diff --git a/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id b/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id index 2dfc5c248..a32267d93 100644 --- a/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id +++ b/src/packages/sqlite-net.1.0.7/content/SQLite.cs.REMOVED.git-id @@ -1 +1 @@ -d2856e3733eb6c7d85057c37ae415e54c8bf2386 \ No newline at end of file +86139d135bd91c43d8ffe8808f0f04975fd22a82 \ No newline at end of file diff --git a/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs b/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs index b4cf34e07..48e064476 100644 --- a/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs +++ b/src/packages/sqlite-net.1.0.7/content/SQLiteAsync.cs @@ -30,115 +30,126 @@ using System.Threading.Tasks; namespace SQLite { - public partial class SQLiteAsyncConnection - { - SQLiteConnectionString _connectionString; - - public SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks = false) - { - _connectionString = new SQLiteConnectionString (databasePath, storeDateTimeAsTicks); - } - - SQLiteConnectionWithLock GetConnection () - { - return SQLiteConnectionPool.Shared.GetConnection (_connectionString); - } - - public Task CreateTableAsync () - where T : new () - { - return CreateTablesAsync (typeof (T)); - } - - public Task CreateTablesAsync () - where T : new () - where T2 : new () - { - return CreateTablesAsync (typeof (T), typeof (T2)); - } - - public Task CreateTablesAsync () - where T : new () - where T2 : new () - where T3 : new () - { - return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3)); - } - - public Task CreateTablesAsync () - where T : new () - where T2 : new () - where T3 : new () - where T4 : new () - { - return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3), typeof (T4)); - } - - public Task CreateTablesAsync () - where T : new () - where T2 : new () - where T3 : new () - where T4 : new () - where T5 : new () - { - return CreateTablesAsync (typeof (T), typeof (T2), typeof (T3), typeof (T4), typeof (T5)); - } - - public Task CreateTablesAsync (params Type[] types) - { - return Task.Factory.StartNew (() => { - CreateTablesResult result = new CreateTablesResult (); - var conn = GetConnection (); - using (conn.Lock ()) { - foreach (Type type in types) { - int aResult = conn.CreateTable (type); - result.Results[type] = aResult; - } - } - return result; - }); - } - - public Task DropTableAsync () - where T : new () - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.DropTable (); - } - }); - } - - public Task InsertAsync (object item) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Insert (item); - } - }); - } - - public Task UpdateAsync (object item) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Update (item); - } - }); - } - - public Task DeleteAsync (object item) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Delete (item); - } - }); - } + public partial class SQLiteAsyncConnection + { + SQLiteConnectionString _connectionString; + + public SQLiteAsyncConnection(string databasePath, bool storeDateTimeAsTicks = false) + { + _connectionString = new SQLiteConnectionString(databasePath, storeDateTimeAsTicks); + } + + SQLiteConnectionWithLock GetConnection() + { + return SQLiteConnectionPool.Shared.GetConnection(_connectionString); + } + + public Task CreateTableAsync() + where T : new() + { + return CreateTablesAsync(typeof(T)); + } + + public Task CreateTablesAsync() + where T : new() + where T2 : new() + { + return CreateTablesAsync(typeof(T), typeof(T2)); + } + + public Task CreateTablesAsync() + where T : new() + where T2 : new() + where T3 : new() + { + return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3)); + } + + public Task CreateTablesAsync() + where T : new() + where T2 : new() + where T3 : new() + where T4 : new() + { + return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3), typeof(T4)); + } + + public Task CreateTablesAsync() + where T : new() + where T2 : new() + where T3 : new() + where T4 : new() + where T5 : new() + { + return CreateTablesAsync(typeof(T), typeof(T2), typeof(T3), typeof(T4), typeof(T5)); + } + + public Task CreateTablesAsync(params Type[] types) + { + return Task.Factory.StartNew(() => + { + CreateTablesResult result = new CreateTablesResult(); + var conn = GetConnection(); + using (conn.Lock()) + { + foreach (Type type in types) + { + int aResult = conn.CreateTable(type); + result.Results[type] = aResult; + } + } + return result; + }); + } + + public Task DropTableAsync() + where T : new() + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.DropTable(); + } + }); + } + + public Task InsertAsync(object item) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Insert(item); + } + }); + } + + public Task UpdateAsync(object item) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Update(item); + } + }); + } + + public Task DeleteAsync(object item) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Delete(item); + } + }); + } public Task GetAsync(object pk) where T : new() @@ -153,18 +164,20 @@ namespace SQLite }); } - public Task FindAsync (object pk) - where T : new () - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Find (pk); - } - }); - } - - public Task GetAsync (Expression> predicate) + public Task FindAsync(object pk) + where T : new() + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Find(pk); + } + }); + } + + public Task GetAsync(Expression> predicate) where T : new() { return Task.Factory.StartNew(() => @@ -172,60 +185,70 @@ namespace SQLite var conn = GetConnection(); using (conn.Lock()) { - return conn.Get (predicate); + return conn.Get(predicate); } }); } - public Task FindAsync (Expression> predicate) - where T : new () - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Find (predicate); - } - }); - } - - public Task ExecuteAsync (string query, params object[] args) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Execute (query, args); - } - }); - } - - public Task InsertAllAsync (IEnumerable items) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.InsertAll (items); - } - }); - } + public Task FindAsync(Expression> predicate) + where T : new() + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Find(predicate); + } + }); + } + + public Task ExecuteAsync(string query, params object[] args) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Execute(query, args); + } + }); + } + + public Task InsertAllAsync(IEnumerable items) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.InsertAll(items); + } + }); + } [Obsolete("Will cause a deadlock if any call in action ends up in a different thread. Use RunInTransactionAsync(Action) instead.")] - public Task RunInTransactionAsync (Action action) - { - return Task.Factory.StartNew (() => { - var conn = this.GetConnection (); - using (conn.Lock ()) { - conn.BeginTransaction (); - try { - action (this); - conn.Commit (); - } - catch (Exception) { - conn.Rollback (); - throw; - } - } - }); - } + public Task RunInTransactionAsync(Action action) + { + return Task.Factory.StartNew(() => + { + var conn = this.GetConnection(); + using (conn.Lock()) + { + conn.BeginTransaction(); + try + { + action(this); + conn.Commit(); + } + catch (Exception) + { + conn.Rollback(); + throw; + } + } + }); + } public Task RunInTransactionAsync(Action action) { @@ -249,238 +272,256 @@ namespace SQLite }); } - public AsyncTableQuery Table () - where T : new () - { - // - // This isn't async as the underlying connection doesn't go out to the database - // until the query is performed. The Async methods are on the query iteself. - // - var conn = GetConnection (); - return new AsyncTableQuery (conn.Table ()); - } - - public Task ExecuteScalarAsync (string sql, params object[] args) - { - return Task.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - var command = conn.CreateCommand (sql, args); - return command.ExecuteScalar (); - } - }); - } - - public Task> QueryAsync (string sql, params object[] args) - where T : new () - { - return Task>.Factory.StartNew (() => { - var conn = GetConnection (); - using (conn.Lock ()) { - return conn.Query (sql, args); - } - }); - } - } - - // - // TODO: Bind to AsyncConnection.GetConnection instead so that delayed - // execution can still work after a Pool.Reset. - // - public class AsyncTableQuery - where T : new () - { - TableQuery _innerQuery; - - public AsyncTableQuery (TableQuery innerQuery) - { - _innerQuery = innerQuery; - } - - public AsyncTableQuery Where (Expression> predExpr) - { - return new AsyncTableQuery (_innerQuery.Where (predExpr)); - } - - public AsyncTableQuery Skip (int n) - { - return new AsyncTableQuery (_innerQuery.Skip (n)); - } - - public AsyncTableQuery Take (int n) - { - return new AsyncTableQuery (_innerQuery.Take (n)); - } - - public AsyncTableQuery OrderBy (Expression> orderExpr) - { - return new AsyncTableQuery (_innerQuery.OrderBy (orderExpr)); - } - - public AsyncTableQuery OrderByDescending (Expression> orderExpr) - { - return new AsyncTableQuery (_innerQuery.OrderByDescending (orderExpr)); - } - - public Task> ToListAsync () - { - return Task.Factory.StartNew (() => { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { - return _innerQuery.ToList (); - } - }); - } - - public Task CountAsync () - { - return Task.Factory.StartNew (() => { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { - return _innerQuery.Count (); - } - }); - } - - public Task ElementAtAsync (int index) - { - return Task.Factory.StartNew (() => { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { - return _innerQuery.ElementAt (index); - } - }); - } - - public Task FirstAsync () - { - return Task.Factory.StartNew(() => { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { - return _innerQuery.First (); - } - }); - } - - public Task FirstOrDefaultAsync () - { - return Task.Factory.StartNew(() => { - using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock ()) { - return _innerQuery.FirstOrDefault (); - } - }); - } + public AsyncTableQuery Table() + where T : new() + { + // + // This isn't async as the underlying connection doesn't go out to the database + // until the query is performed. The Async methods are on the query iteself. + // + var conn = GetConnection(); + return new AsyncTableQuery(conn.Table()); + } + + public Task ExecuteScalarAsync(string sql, params object[] args) + { + return Task.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + var command = conn.CreateCommand(sql, args); + return command.ExecuteScalar(); + } + }); + } + + public Task> QueryAsync(string sql, params object[] args) + where T : new() + { + return Task>.Factory.StartNew(() => + { + var conn = GetConnection(); + using (conn.Lock()) + { + return conn.Query(sql, args); + } + }); + } + } + + // + // TODO: Bind to AsyncConnection.GetConnection instead so that delayed + // execution can still work after a Pool.Reset. + // + public class AsyncTableQuery + where T : new() + { + TableQuery _innerQuery; + + public AsyncTableQuery(TableQuery innerQuery) + { + _innerQuery = innerQuery; + } + + public AsyncTableQuery Where(Expression> predExpr) + { + return new AsyncTableQuery(_innerQuery.Where(predExpr)); + } + + public AsyncTableQuery Skip(int n) + { + return new AsyncTableQuery(_innerQuery.Skip(n)); + } + + public AsyncTableQuery Take(int n) + { + return new AsyncTableQuery(_innerQuery.Take(n)); + } + + public AsyncTableQuery OrderBy(Expression> orderExpr) + { + return new AsyncTableQuery(_innerQuery.OrderBy(orderExpr)); + } + + public AsyncTableQuery OrderByDescending(Expression> orderExpr) + { + return new AsyncTableQuery(_innerQuery.OrderByDescending(orderExpr)); + } + + public Task> ToListAsync() + { + return Task.Factory.StartNew(() => + { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) + { + return _innerQuery.ToList(); + } + }); + } + + public Task CountAsync() + { + return Task.Factory.StartNew(() => + { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) + { + return _innerQuery.Count(); + } + }); + } + + public Task ElementAtAsync(int index) + { + return Task.Factory.StartNew(() => + { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) + { + return _innerQuery.ElementAt(index); + } + }); + } + + public Task FirstAsync() + { + return Task.Factory.StartNew(() => + { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) + { + return _innerQuery.First(); + } + }); + } + + public Task FirstOrDefaultAsync() + { + return Task.Factory.StartNew(() => + { + using (((SQLiteConnectionWithLock)_innerQuery.Connection).Lock()) + { + return _innerQuery.FirstOrDefault(); + } + }); + } + } + + public class CreateTablesResult + { + public Dictionary Results { get; private set; } + + internal CreateTablesResult() + { + this.Results = new Dictionary(); + } } - public class CreateTablesResult - { - public Dictionary Results { get; private set; } - - internal CreateTablesResult () - { - this.Results = new Dictionary (); - } - } - - class SQLiteConnectionPool - { - class Entry - { - public SQLiteConnectionString ConnectionString { get; private set; } - public SQLiteConnectionWithLock Connection { get; private set; } - - public Entry (SQLiteConnectionString connectionString) - { - ConnectionString = connectionString; - Connection = new SQLiteConnectionWithLock (connectionString); - } - - public void OnApplicationSuspended () - { - Connection.Dispose (); - Connection = null; - } - } - - readonly Dictionary _entries = new Dictionary (); - readonly object _entriesLock = new object (); - - static readonly SQLiteConnectionPool _shared = new SQLiteConnectionPool (); - - /// - /// Gets the singleton instance of the connection tool. - /// - public static SQLiteConnectionPool Shared - { - get - { - return _shared; - } - } - - public SQLiteConnectionWithLock GetConnection (SQLiteConnectionString connectionString) - { - lock (_entriesLock) { - Entry entry; - string key = connectionString.ConnectionString; - - if (!_entries.TryGetValue (key, out entry)) { - entry = new Entry (connectionString); - _entries[key] = entry; - } - - return entry.Connection; - } - } - - /// - /// Closes all connections managed by this pool. - /// - public void Reset () - { - lock (_entriesLock) { - foreach (var entry in _entries.Values) { - entry.OnApplicationSuspended (); - } - _entries.Clear (); - } - } - - /// - /// Call this method when the application is suspended. - /// - /// Behaviour here is to close any open connections. - public void ApplicationSuspended () - { - Reset (); - } - } - - class SQLiteConnectionWithLock : SQLiteConnection - { - readonly object _lockPoint = new object (); - - public SQLiteConnectionWithLock (SQLiteConnectionString connectionString) - : base (connectionString.DatabasePath, connectionString.StoreDateTimeAsTicks) - { - } - - public IDisposable Lock () - { - return new LockWrapper (_lockPoint); - } - - private class LockWrapper : IDisposable - { - object _lockPoint; - - public LockWrapper (object lockPoint) - { - _lockPoint = lockPoint; - Monitor.Enter (_lockPoint); - } - - public void Dispose () - { - Monitor.Exit (_lockPoint); - } - } - } + class SQLiteConnectionPool + { + class Entry + { + public SQLiteConnectionString ConnectionString { get; private set; } + public SQLiteConnectionWithLock Connection { get; private set; } + + public Entry(SQLiteConnectionString connectionString) + { + ConnectionString = connectionString; + Connection = new SQLiteConnectionWithLock(connectionString); + } + + public void OnApplicationSuspended() + { + Connection.Dispose(); + Connection = null; + } + } + + readonly Dictionary _entries = new Dictionary(); + readonly object _entriesLock = new object(); + + static readonly SQLiteConnectionPool _shared = new SQLiteConnectionPool(); + + /// + /// Gets the singleton instance of the connection tool. + /// + public static SQLiteConnectionPool Shared + { + get + { + return _shared; + } + } + + public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString) + { + lock (_entriesLock) + { + Entry entry; + string key = connectionString.ConnectionString; + + if (!_entries.TryGetValue(key, out entry)) + { + entry = new Entry(connectionString); + _entries[key] = entry; + } + + return entry.Connection; + } + } + + /// + /// Closes all connections managed by this pool. + /// + public void Reset() + { + lock (_entriesLock) + { + foreach (var entry in _entries.Values) + { + entry.OnApplicationSuspended(); + } + _entries.Clear(); + } + } + + /// + /// Call this method when the application is suspended. + /// + /// Behaviour here is to close any open connections. + public void ApplicationSuspended() + { + Reset(); + } + } + + class SQLiteConnectionWithLock : SQLiteConnection + { + readonly object _lockPoint = new object(); + + public SQLiteConnectionWithLock(SQLiteConnectionString connectionString) + : base(connectionString.DatabasePath, connectionString.StoreDateTimeAsTicks) + { + } + + public IDisposable Lock() + { + return new LockWrapper(_lockPoint); + } + + private class LockWrapper : IDisposable + { + object _lockPoint; + + public LockWrapper(object lockPoint) + { + _lockPoint = lockPoint; + Monitor.Enter(_lockPoint); + } + + public void Dispose() + { + Monitor.Exit(_lockPoint); + } + } + } }