Skip to content

Commit

Permalink
refactor: repositories to use dispose pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxelr committed Mar 5, 2024
1 parent e1a8dd4 commit 3032efe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Repositories/SendGridRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ public IEmailRepository To(ICollection<string> to)
/// </summary>
public void Dispose()
{
Message = null;
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
Message = null;
}
}
12 changes: 10 additions & 2 deletions src/Repositories/SmtpRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,16 @@ public async Task<bool> SendAsync()
/// </summary>
public void Dispose()
{
client?.Dispose();
Message?.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
client?.Dispose();
Message?.Dispose();
}
}
}

0 comments on commit 3032efe

Please sign in to comment.