-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FE 1443: refactor default constructor (#163)
* create DefaultClientIO via Builder * Builder pattern implementation for DefaultClientIO class Co-authored-by: Gennadii Shestakov <shestakov,[email protected]>
- Loading branch information
1 parent
ecffe02
commit a5c58cf
Showing
3 changed files
with
123 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
|
||
namespace FaunaDB.Client | ||
{ | ||
/// <summary> | ||
/// Builder class for DefaultClientIO class | ||
/// </summary> | ||
internal class Builder | ||
{ | ||
internal AuthenticationHeaderValue AuthHeader { get; private set; } | ||
|
||
internal LastSeen LastSeen { get; private set; } | ||
|
||
internal HttpClient Client { get; private set; } | ||
|
||
internal string Secret { get; private set; } | ||
|
||
internal Uri Endpoint { get; private set; } | ||
|
||
internal TimeSpan? Timeout { get; private set; } | ||
|
||
internal IReadOnlyDictionary<string, string> CustomHeaders { get; private set; } | ||
|
||
internal Version HttpVersion { get; private set; } | ||
|
||
internal Builder SetLastSeen(LastSeen lastSeen) | ||
{ | ||
LastSeen = lastSeen; | ||
return this; | ||
} | ||
|
||
internal Builder SetClient(HttpClient client) | ||
{ | ||
Client = client; | ||
return this; | ||
} | ||
|
||
internal Builder SetSecret(string secret) | ||
{ | ||
Secret = secret; | ||
return this; | ||
} | ||
|
||
internal Builder SetEndpoint(Uri endpoint) | ||
{ | ||
Endpoint = endpoint; | ||
return this; | ||
} | ||
|
||
internal Builder SetTimeout(TimeSpan? timeout) | ||
{ | ||
Timeout = timeout; | ||
return this; | ||
} | ||
|
||
internal Builder SetCustomHeaders(IReadOnlyDictionary<string, string> customHeaders) | ||
{ | ||
CustomHeaders = customHeaders; | ||
return this; | ||
} | ||
|
||
internal Builder SetHttpVersion(Version httpVersion) | ||
{ | ||
HttpVersion = httpVersion; | ||
return this; | ||
} | ||
|
||
internal Builder SetAuthHeader(AuthenticationHeaderValue authHeader) | ||
{ | ||
AuthHeader = authHeader; | ||
return this; | ||
} | ||
|
||
internal DefaultClientIO Build() | ||
{ | ||
return new DefaultClientIO(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters