I'd like to know if it is possible to do the following:
using (MyClass o = new MyClass())
{
TheClassIWantMyClassToSee x = new TheClassIWantMyClassToSee();
x.DoStuff();
}
I'd like to create a class (MyClass) and use it in a using block. Inside this block, I want to work with objects of a certain type (TheClassIWantMyClassToSee). When using block falls out of scope, I want to perform certain actions on these (TheClassIWantMyClassToSee) objects.
Is it possible to make a class aware of other objects declared in its scope transparently?
I realise that I could add object instances to the MyClass object, but I'd like to make it easier for developers working with the API I'm building.
Any ideas are welcome.
Thanks.