public void SimpleDelegateFromMethod()
        {
            Delegates   target = new Delegates();
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(10);
        }
        public void DelegateFromSaticMethod()
        {
            Delegates target = new Delegates();
            Int32Action action = new Int32Action(Delegates.StaticRob);

            action.Invoke(7);
        }
        public void SingleDelegateMethodFromMethod()
        {
            Delegates target = new Delegates("John");
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(5);
            action(6);
        }
        public void MultiCast()
        {
            Int32Action action1 = new Int32Action(Delegates.StaticRob);
            Int32Action action2 = new Int32Action(Delegates.StaticRob2);

            Int32Action action3 = action1 + action2;
            action3(20);
        }
        public void Method_Can_Be_Invoked_Via_Delegate()
        {
            var target = new Target("Jon");
            var action = new Int32Action(target.RandomRob);

            action.Invoke(5); //Invoke can be omitted.
            action(6);
        }
Esempio n. 6
0
        public void SimpleDelegatesFromMethod()
        {
            var         mytarget = new Delegates();
            Int32Action action   = mytarget.DoIt;

            Int32Action action2 = action + mytarget.RandomRob;

            action2.Invoke(4);
        }
        public void Multicast()
        {
            Int32Action action1 = new Int32Action(Delegates.StaticRob1);
            Int32Action action2 = new Int32Action(Delegates.StaticRob2);

            Int32Action action3 = action1 + action2;

            action3(20);
        }
        public void Delegates_Can_Be_Combined_For_Multicast()
        {
            var action1 = new Int32Action(Target.StaticRob1);
            var action2 = new Int32Action(Target.StaticRob2);

            var action3 = action1 + action2;

            action3(20);
        }
Esempio n. 9
0
        public void MultiCast()
        {
            Int32Action action1 = new Int32Action(Delegates.StaticNoel);
            Int32Action action2 = new Int32Action(Delegates.StaticNoel2);

            Int32Action action3 = action1 + action2;

            action1 = null;
            action3(20);
        }
Esempio n. 10
0
        public void Musticast()
        {
            Int32Action action  = new Int32Action(Delegates.StaticRob);
            Int32Action action2 = new Int32Action(Delegates.StaticRob2);

            Int32Action action3 = action + action2;

            action3(20);
            Int32Action action4 = (Int32Action)Delegate.Combine(action, action2);

            action4(21);
        }
Esempio n. 11
0
        public void SimpleDelegateFormMethod()
        {
            Delegates   target = new Delegates();
            Int32Action action = new Int32Action(target.RandomRob);

            action.Invoke(5);
            action(6);

            var person = new
            {
                Name         = "Obinna",
                EmailAddress = "*****@*****.**"
            };

            Console.WriteLine(person.ToString());
        }
Esempio n. 12
0
        public void Delegatesfromstaticmethod()
        {
            Int32Action staticdelegate = Delegates.StaticBill;

            staticdelegate(34);
        }
Esempio n. 13
0
        public void DeligateStaticMethod()
        {
            Int32Action action = new Int32Action(Delegates.StaticRob);

            action.Invoke(7);
        }
Esempio n. 14
0
        public void DelegateFromStaticMethod()
        {
            Int32Action action = new Int32Action(Delegates.StaticRob1);

            action.Invoke(8);
        }
        public void Static_Method_Can_Be_Called_Via_Delegate()
        {
            var action = new Int32Action(Target.StaticRob1);

            action(5);
        }