public void CannotBindToEventAsProperty() { dynamic d = new TypeWithEvent(); Assert.Throws <RuntimeBinderException>(() => d.Event = 3); Assert.Throws <RuntimeBinderException>(() => { int x = d.Event; }); }
static void Main(string[] args) { var typeWithEvent = new TypeWithEvent(); var typeWithEventHandler = new TypeWithEventHandler(); SubscribeEvent("EventTest", "EventHandlerMethod", typeWithEvent, typeWithEventHandler); EventArgs e = new EventArgs(); Console.WriteLine("Event is about to be raised."); typeWithEvent.OnTimeToRaiseTheEvent(e); Console.WriteLine("Event trigger is completed."); Console.ReadLine(); }
public void CannotBindToEventAsInvokable() { dynamic d = new TypeWithEvent(); Assert.Throws <RuntimeBinderException>(() => d.Event(new EventArgs())); }