B
Brett Wiltshire
Is it possible to check whether an object (this) has been instantiated
as the target of a using block?
e.g.
public class MyClass : IDisposable
{
public MyClass()
{
if ( ! ThisObjectIntantiatedByUsingBlock() )
{
throw new ApplicationException ( "This class can only be
invoked as the target of a 'using' block." );
}
// whatever
}
public void Dispose()
{
// whatever
}
}
Since a using block expands out to a try/catch/finally I'm guessing
not, but thought I'd plumb the collective depths of your expertise,
just in case.
Cheers,
Brett.
as the target of a using block?
e.g.
public class MyClass : IDisposable
{
public MyClass()
{
if ( ! ThisObjectIntantiatedByUsingBlock() )
{
throw new ApplicationException ( "This class can only be
invoked as the target of a 'using' block." );
}
// whatever
}
public void Dispose()
{
// whatever
}
}
Since a using block expands out to a try/catch/finally I'm guessing
not, but thought I'd plumb the collective depths of your expertise,
just in case.
Cheers,
Brett.