I am looking at code that takes an IBar
object bar which is really a .net remoting transparent proxy (RuntimeServices.IsTransparentProxy true) and, for a set of IFoo
types, does this:
var fooValue = bar as IFoo; // BTW, IFoo is always derived from IBar! But not sure if it matters
if (fooValue != null)
// and then eventually call some method on IFoo, we can imagine.
Unfortunately this type-casting isn't performing very well, it seems to use a lot of CPU time. What might a better way to do this be? (Unfortunately since it's a transparent proxy you can't do bar.GetType().GetInterfaces()...
)