Is there any tool or library that will let me easily wrap a class, say DbDataReader with another class called, say WDbDataReader, for debugging purposes?
My particular problem is that I think my code is not properly calling DbDataReader's Dispose. I first though about subclassing DbDataReader and having a sta开发者_StackOverflowtic int that counts created instances that have not been disposed. The problem is that I don't create the instance from my code but by calling OleDbCommand's ExecuteReader method.
So now I want to create a class that would look something like this:
public class WDbDataReader
{
private static int _Counter = 0;
private DbDataReader _Source;
public WDbDataReader(DbDataReader source)
{
_Source = source;
_Counter++;
}
public void Dispose()
{
_Counter--;
_Source.Dispose();
}
// implement all used DbDataReader methods here
}
And then surround all calls to OleDbCommand's ExecuteReader method with a new WDbDataReader(...). So I was wondering if there is a quicker or automated way to do this because I might need to do it for several other classes in the future.
I'm not sure but I believe I could use Pex or Moles for this purpose. But I've been checking their tutorials and I believe that's way more advanced that what I need right now.
加载中,请稍侯......
精彩评论