oysteinkrog/SQLite.Net-PCL — pull request #16 by jamesottaway (2014-04-17 12:34:14+00:00)
Title: Expose whether the SQLiteConnectionWithLock is locked

I want to enforce the `SQLiteConnectionWithLock` to be locked before calling any other methods on it, such as `Table()`.

Given a wrapper class around `SQLiteConnectionWithLock`, like so:

```
public class Repository
{
protected readonly SQLiteConnectionWithLock connection;

public BaseRepository(SQLiteConnectionWithLock connection)
{
this.connection = connection;
connection.CreateTable();
}

public IEnumerable All()
{
AssertConenctionLocked();
return connection.Table();
}

public IDisposable Lock()
{
return connection.Lock();
}

private void AssertConenctionLocked()
{
if (!connection.IsLocked()) throw new NotLockedException();
}
}
```

This allows me to enforce the call to `repository.Lock()` before `repository.All()`, so the following code will fail:

```
var connection = GetConnection();
var repository = new Repository(connection);
repository.All();
```

but this won't:

```
var connection = GetConnection();
var repository = new Repository(connection);

using (repository.Lock()) {
repository.All();
}
```