Skip to content

Commit 47b5c82

Browse files
committed
Implemented Dispose(bool)
Added .nvmrc
1 parent 0bd1795 commit 47b5c82

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/RestSharp/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v17.0.1

src/RestSharp/RestClient.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,18 @@ void DoBuildUriValidations(RestRequest request) {
193193
);
194194
}
195195

196+
readonly bool _disposeHttpClient;
197+
bool _disposed;
198+
199+
protected virtual void Dispose(bool disposing) {
200+
if (disposing && !_disposed) {
201+
_disposed = true;
202+
if (_disposeHttpClient) HttpClient.Dispose();
203+
}
204+
}
205+
196206
public void Dispose() {
197-
if (_disposeHttpClient) HttpClient.Dispose();
207+
Dispose(true);
198208
GC.SuppressFinalize(this);
199209
}
200-
201-
readonly bool _disposeHttpClient;
202210
}

0 commit comments

Comments
 (0)