Пример #1
0
        public void AddFunctionAsPersonEventHandler()
        {
            Person person = new Person() { FirstName = "Adam" };
            NameListener listener = new NameListener();
            ObjectUtilities.AddHandler(person, "NameEvent", listener, null);
            person.GetName();

            Assert.AreEqual(4, listener.Length);
            Assert.AreEqual("Adam", listener.Name);
        }
Пример #2
0
        public void AddEventHandlerToPerson()
        {
            NameListener listener = new NameListener();
            Person person = new Person() { FirstName = "Adam" };
            FunctionWrapper<string, int, MyEvent> wrapper = new FunctionWrapper<string, int, MyEvent>(listener, null);
            typeof(Person).GetEvent("NameEvent").AddEventHandler(person, wrapper.CreateFunctionDelegate());
            person.GetName();

            Assert.AreEqual(4, listener.Length);
            Assert.AreEqual("Adam", listener.Name);
        }
Пример #3
0
        public void AddFunctionAsPersonEventHandler()
        {
            Person person = new Person()
            {
                FirstName = "Adam"
            };
            NameListener listener = new NameListener();

            ObjectUtilities.AddHandler(person, "NameEvent", listener, null);
            person.GetName();

            Assert.AreEqual(4, listener.Length);
            Assert.AreEqual("Adam", listener.Name);
        }
Пример #4
0
        public void AddEventHandlerToPerson()
        {
            NameListener listener = new NameListener();
            Person       person   = new Person()
            {
                FirstName = "Adam"
            };
            FunctionWrapper <string, int, MyEvent> wrapper = new FunctionWrapper <string, int, MyEvent>(listener, null);

            typeof(Person).GetEvent("NameEvent").AddEventHandler(person, wrapper.CreateFunctionDelegate());
            person.GetName();

            Assert.AreEqual(4, listener.Length);
            Assert.AreEqual("Adam", listener.Name);
        }