Dispose()
does not reset the pointer to null. So the ISDisposedChecker function does not work this way..
Dispose isn't a destructor..
I wouldn't implement a dispose-checker, I would put the Dispose responsibility to the caller method if you want to return the SqlCommand as result.
private SqlCommand Command()
{
cmd = new SqlCommand(QueryStr, Connection);
return cmd;
}
private void Test()
{
// a using block is very safe, it will dispose the command
// even when exceptions are thrown.
using(SqlCommand command = Command())
{
// do your thing....
}
}