Saw this. Why the explicit cast to IDisposable? Is this just a shorthand to ensure that IDisposable is called on exiting the using block?
using (proxy as IDi
This could be required if you are given a proxy
instance from somewhere and its static type does not implement IDisposable
but you know that the real type may do and you want to make sure it will be disposed e.g.
public class Proxy : ISomeInterface, IDisposable
{
...
}
private ISomeInterface Create() { ... }
ISomeInterface proxy = Create();
//won't compile without `as`
using(proxy as IDisposable)
{
...
}