Hi,
Let's say that I need to design 50 methods, each one of which look like this:
try{
if(Shutdown.Instance.IsShuttingDown){
return;
}
DisposeLock.AcquireReaderLock(Timeout.Infinite);
if(IsDisposed){
throw new AppShutdownException();
}
/* Custom Code Here !*/
}
catch(AppShutdownException){}
finally{
DisposeLock.ReleaseReaderLock();
}
So basically, each method looks like the one above. The only thing that differentiates one method from another is the custom code which will be placed in the area which I've designated with the comment block.
I'm wondering if C# supports some sort of "macro" that would allow me to substitute an abbreviation representing the repetative wrapper code that is placed before and after the custom code. MFC allowed this. C# does something similar via it's "using" directive which encapsulates try/finally/dispose logic, but I'm not certain if C# allows developers to create their own macros.
Any ideas?
Thanks,
Jackson