How would you implement the Cast<T>()
method of linq on single objects?
Here's the scenario:
public interface IFoo
{
String Message { get; set; }
}
public class Foo : IFoo
{
IFoo.Message { get; set; }
internal SecretMessage { get; set; } // secrets are internal to the assembly
}
internal class Fubar
{
public IFoo Foo { get; set; }
}
I'd like to be able to do...
fubarInstance.Foo.Cast<Foo>.SecretMessage = "";
Instead of...
((Foo)fubarInstance.Foo).SecretMessage = "";