Ejemplo n.º 1
0
        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();
    }
Ejemplo n.º 3
0
        public void CannotBindToEventAsInvokable()
        {
            dynamic d = new TypeWithEvent();

            Assert.Throws <RuntimeBinderException>(() => d.Event(new EventArgs()));
        }