Skip to content

Commit db0e034

Browse files
Changes from FlurlClient to IFlurlClient and minor code style updates.
1 parent 178f0b1 commit db0e034

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/CouchDB.Driver/CouchClient.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class CouchClient : IDisposable
2323
private DateTime? _cookieCreationDate;
2424
private string _cookieToken;
2525
private readonly CouchSettings _settings;
26-
private readonly FlurlClient _flurlClient;
26+
private readonly IFlurlClient _flurlClient;
2727
private readonly string[] _systemDatabases = new[] { "_users", "_replicator", "_global_changes" };
2828
public string ConnectionString { get; private set; }
2929

@@ -44,9 +44,7 @@ public CouchClient(string connectionString, Action<CouchSettings> couchSettingsF
4444
couchSettingsFunc?.Invoke(_settings);
4545

4646
ConnectionString = connectionString;
47-
_flurlClient = new FlurlClient(connectionString);
48-
49-
_flurlClient.Configure(s =>
47+
_flurlClient = new FlurlClient(connectionString).Configure(s =>
5048
{
5149
s.BeforeCall = OnBeforeCall;
5250
if (_settings.ServerCertificateCustomValidationCallback != null)

src/CouchDB.Driver/CouchDatabase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace CouchDB.Driver
2222
public class CouchDatabase<TSource> where TSource : CouchDocument
2323
{
2424
private readonly QueryProvider _queryProvider;
25-
private readonly FlurlClient _flurlClient;
25+
private readonly IFlurlClient _flurlClient;
2626
private readonly CouchSettings _settings;
2727
private readonly string _connectionString;
2828

@@ -36,7 +36,7 @@ public class CouchDatabase<TSource> where TSource : CouchDocument
3636
/// </summary>
3737
public CouchSecurity Security { get; }
3838

39-
internal CouchDatabase(FlurlClient flurlClient, CouchSettings settings, string connectionString, string db)
39+
internal CouchDatabase(IFlurlClient flurlClient, CouchSettings settings, string connectionString, string db)
4040
{
4141
_flurlClient = flurlClient ?? throw new ArgumentNullException(nameof(flurlClient));
4242
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
@@ -262,12 +262,12 @@ public Task<List<TSource>> QueryAsync(object mangoQuery)
262262

263263
private async Task<List<TSource>> SendQueryAsync(Func<IFlurlRequest, Task<HttpResponseMessage>> requestFunc)
264264
{
265-
var request = NewRequest()
265+
IFlurlRequest request = NewRequest()
266266
.AppendPathSegment("_find");
267267

268-
var message = requestFunc(request);
268+
Task<HttpResponseMessage> message = requestFunc(request);
269269

270-
var findResult = await message
270+
FindResult<TSource> findResult = await message
271271
.ReceiveJson<FindResult<TSource>>()
272272
.SendRequestAsync()
273273
.ConfigureAwait(false);
@@ -281,7 +281,7 @@ private async Task<List<TSource>> SendQueryAsync(Func<IFlurlRequest, Task<HttpRe
281281
/// <returns></returns>
282282
public async Task<List<TSource>> FindManyAsync(IEnumerable<string> docIds)
283283
{
284-
var bulkGetResult = await NewRequest()
284+
BulkGetResult<TSource> bulkGetResult = await NewRequest()
285285
.AppendPathSegment("_bulk_get")
286286
.PostJsonAsync(new
287287
{

src/CouchDB.Driver/CouchQueryProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ namespace CouchDB.Driver
1212
{
1313
internal class CouchQueryProvider : QueryProvider
1414
{
15-
private readonly FlurlClient _flurlClient;
15+
private readonly IFlurlClient _flurlClient;
1616
private readonly CouchSettings _settings;
1717
private readonly string _connectionString;
1818
private readonly string _db;
1919

20-
public CouchQueryProvider(FlurlClient flurlClient, CouchSettings settings, string connectionString, string db)
20+
public CouchQueryProvider(IFlurlClient flurlClient, CouchSettings settings, string connectionString, string db)
2121
{
2222
_flurlClient = flurlClient ?? throw new ArgumentNullException(nameof(flurlClient));
2323
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
@@ -33,7 +33,7 @@ public override string GetQueryText(Expression expression)
3333
public override object Execute(Expression e, bool completeResponse)
3434
{
3535
var body = Translate(e);
36-
var elementType = TypeSystem.GetElementType(e.Type);
36+
Type elementType = TypeSystem.GetElementType(e.Type);
3737

3838
MethodInfo method = typeof(CouchQueryProvider).GetMethod("GetCouchList");
3939
MethodInfo generic = method.MakeGenericMethod(elementType);
@@ -48,7 +48,7 @@ private string Translate(Expression expression)
4848

4949
public CouchList<T> GetCouchList<T>(string body)
5050
{
51-
var result = _flurlClient
51+
FindResult<T> result = _flurlClient
5252
.Request(_connectionString)
5353
.AppendPathSegments(_db, "_find")
5454
.WithHeader("Content-Type", "application/json")

0 commit comments

Comments
 (0)