Support for IDisposable?
See original GitHub issueYour example code:
public interface IGitHubApi
{
[Get("users/{userId}")]
Task<User> GetUserAsync([Path] string userId);
}
IGitHubApi api = RestClient.For<IGitHubApi>("https://api.github.com");
User user = await api.GetUserAsync("canton7");
If I want to dispose the RestClient after use, is this possible like:
public interface IGitHubApi : IDisposable
{
[Get("users/{userId}")]
Task<User> GetUserAsync([Path] string userId);
}
using (IGitHubApi api = RestClient.For<IGitHubApi>("https://api.github.com"))
{
User user = await api.GetUserAsync("canton7");
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
IDisposable Interface (System)
Documentation for types that implement IDisposable note that fact and include a reminder to call its Dispose implementation. The C#, F#, and Visual...
Read more >c# - Implementing IDisposable (the Disposable Pattern) as ...
My implementation. So, here is the solution I came up with. public class DisposeService<T> where T : IDisposable { private readonly T ...
Read more >How to use IDisposable in ASP.NET Core
The simplest way to dispose an IDisposable instance is by using the “using” statement, which calls the Dispose method on the instance ...
Read more >All about IDisposable
All classes that support disposing extend IDisposable interface. // unmanaged resources. It's a primitive one defining only one method – ...
Read more >Support IDisposable for Function Handlers · Issue #342
I considered using a destructor, but believe the shared contract of IDisposable is a better solution overall.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here with some discussion.
Thanks.