title: .NET Core Dispose implementation
body: <p>I'm a little confused how to implement Dispose pattern correctly.</p>
  
  <p>I have a class:</p>
  
  <pre><code>public class DomainActions : IDomainActions, IDisposable
  {
      private HttpClient _client;
  
      public DomainActions(string baseAddress, string token)
      {
          _client = new HttpClient();
          _client.BaseAddress = new Uri(baseAddress);
          _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
  
      }
  
      public async Task&lt;List&lt;DomainDto&gt;&gt; GetDomainListAsync()
      {
          var requestStream = await _client.GetAsync("domains");
          var requestString = await requestStream.Content.ReadAsStringAsync();
  
          return ParseDomainListResponse(requestString);
  
      }
  </code></pre>
  
  <p>as I understand, I have to allocate <code>_client</code></p>
  
  <pre><code>public class DomainActions : IDomainActions
  {
      //...
      public void Dispose()
      {
          Dispose(true);
          GC.SuppressFinalize(this);
      }
  
      private bool _disposed = false;
      public virtual void Dispose(bool disposing)
      {
          if (_disposed) return;
          if (disposing)
          {
              if (_client != null)
              {
                  _client.Dispose();
                  _client = null;
              }
          }
          _disposed = true;
      }
  }
  </code></pre>
  
  <p>my implemetation is correct, is it enough?</p>