Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created October 8, 2010 12:46
Show Gist options
  • Save jfromaniello/616727 to your computer and use it in GitHub Desktop.
Save jfromaniello/616727 to your computer and use it in GitHub Desktop.
//Option 1
public class Service : IDisposable
{
public Service (IConnectionProvider connectionProvider)
{
this.connection = connectionProvider.CreateConnection();
}
public void Dispose()
{
connection.Dispose();
}
}
//Option 2
public class Service : IDisposable
{
public Service (IConnectionProvider connectionProvider)
{
this.connectionProvider = connectionProvider;
this.connection = connectionProvider.CreateConnection();
}
public void Dispose()
{
connectionProvider.Release(connection);
}
}
@fabiomaulo
Copy link

public class TuControler : IDisposable
{
public TuController(IConnectionProvider connectionProvider)
{
this.connection = connectionProvider.GetConnection();
}

public void Dispose()
{
connection.Dispose();
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment