static void Main(string[] args) { int i = 1; dynamic d = new Duck(); d.Test = i; dynamic a = d.Test; Console.WriteLine(a); Console.WriteLine(a.GetType().FullName); // Duck!? IQuack t = d; Console.WriteLine(t.Test); t.Test = "2"; // Would not compile anymore: // t.Test = i; Console.WriteLine(t.Test); try { Console.WriteLine(t.NotSet); Console.WriteLine("You should never see this"); } catch (MemberAccessException) { Console.WriteLine("Caught expected MemberAccessException"); } t.NotSet = "3"; Console.WriteLine("Should work now: " + t.NotSet); Console.WriteLine("Done"); Console.Read(); }
public DuckInterceptor(Duck dynamicElement) { // TODO: Complete member initialization this.dynamicElement = dynamicElement; }
public static object GenerateProxy(Type type, Duck element) { return g.CreateInterfaceProxyWithoutTarget(type, new DuckInterceptor(element)); }
public MetaDuck(System.Linq.Expressions.Expression expression, Duck duck) : base(expression, Restrictions.Empty, duck) { }