Whoops just saw yesterday's message came in all garbled..
here it is again properly formatted..
==========================
Hi again Gishu and all,?
Seems like this thread has grown since I last looked :)
What I used to do in this case is inject the disposable object as a collaborator (interface representing its role) into the class that uses it,?
so the class that uses it doesn't need to know about if it is or isn't disposable.
E.g:?
class connection?
{
?ISecurePassword pswd?
}
interface ISecurePassword?
{?
?Void doSomethingThatSecurePasswordsDo();?
}
class DispisableSecurePassword : ISecurePassword, IDisposable
{
? ...?
}
Application:
void Main(){
? using (DisposableSecurePassword pswd = new DisposableSecurePassword())
? {
? ? Connection conn = new connection(pswd):
? ? conn.DoSomethingThatNeedsToBeDone();
? }
}
Makes any sense??
Written hastily from iPhone waiting for a buss
Avi