i am trying to find a way to 'thouroughly' manually garbage dispose of CLR objects when i use them.
In many .Net centric programming languages now you have the concept of a "using block", and once you leave the "using block" (like leaving a local function) all objects that can be disposed are disposed.
So i don't have a using mechanism, but i would like to create a mechanism (for now, lets call it a global subroutine)
that i can send each CLR object to...that asks
can this object be disposed, and if so call it's disposed method
I was reading an article on https://csharp.2000things.com/2013/09/30/941-checking-to-see-if-objects-are-disposable/
If a type implements the IDisposable interface, you should always call the Dispose method on an instance of the class when you are done using it. The presence of IDisposable indicates that the class has some resources that can be released prior to garbage collection.
Below is one pattern for checking to see if an object implements the IDisposable interface.
Dog bob = new Dog("Bob", 5);
if (bob is IDisposable) ((IDisposable)bob).Dispose();
so, in winbatch CLR integration, assuming i have a variable that is a CLR object
(lets say i set ObjSearcher = ObjectCLRNew( 'System.DirectoryServices.DirectorySearcher')
and i use it, i'm done with it, etc.
In winbatch how can i programically know if objSearcher "implements the IDisposable interface", and if that is way to complicated.. then can I "query" if it has a .Dispose() method?