示例#1
0
    public static S9 NewS9(int i32, TestDelegate1 testDel1)
    {
        S9 s9 = new S9();

        s9.i32         = i32;
        s9.myDelegate1 = testDel1;
        return(s9);
    }
        public void TestDefaultListenerMethod()
        {
            var called = new AtomicBoolean(false);
            var dele   = new TestDelegate1(called);

            adapter.Instance = dele;
            var bytes = EncodingUtils.GetDefaultEncoding().GetBytes("foo");

            adapter.OnMessage(Message.Create(bytes, messageProperties), null);
            Assert.True(called.Value);
        }
示例#3
0
        public void TestPredicate()
        {
            //Custom delegate can be written inside a method
            Predicate <int> testPredicate = IsEvenNumber;
            var             result        = testPredicate(15);
            Predicate <int> tPredicate    = delegate(int x) { return(x % 2 == 0); };
            //x => x % 2 == 0;

            TestDelegate testDelB = delegate(string s) { Console.WriteLine(s); };

            testDelB += delegate(string str) { };
            TestDelegate  testDelC = (x) => { Console.WriteLine(x); };
            TestDelegate1 test     = () => { return(5 * 5); };
        }
示例#4
0
 public int callDelegate1(TestDelegate1 del)
 {
     return del(2, 3);
 }
示例#5
0
 public int callDelegate1(TestDelegate1 del)
 {
     return(del(2, 3));
 }
示例#6
0
 public static S9 NewS9(int i32, TestDelegate1 testDel1)
 {
     S9 s9 = new S9();
     s9.i32 = i32;
     s9.myDelegate1 = testDel1;
     return s9;
 }
 private void TestFun1(TestDelegate1 de)
 {
     de("test", 1000);
 }
 // Use this for initialization
 void Start()
 {
     mDelegate1 = new TestDelegate1(StaticDelegateFun);
     mDelegate2 = new TestDelegate2 <string, int>(StaticDelegateFun);
 }
示例#9
0
    static void Main(string[] args)
    {
        // Generic Action
        Action<string, ConsoleColor, int> actionTarget =
            new Action<string, ConsoleColor, int>(ActionFuncDel.DisplayMessage);
        actionTarget("yo action", ConsoleColor.Yellow, 5);

        Func<int, int, int> funcTarget1 =
            new Func<int, int, int>(ActionFuncDel.Add);
        int ret = funcTarget1(70, 80);
        Console.WriteLine("Func<int,int,int> ret = {0}", ret);

        Func<int, int, string> funcTarget2 =
            new Func<int, int, string>(ActionFuncDel.SumToString);
        string strRet = funcTarget2(90, 300);
        Console.WriteLine("Func<int,int,string> ret = {0}", strRet);

        // Generic Delegate demo
        GenDel.TestGenDelegate();

        TestCar();

        TestMath();

        TestDelegate1 td1 = new TestDelegate1();
        td1.TestNumberChanger();
        TestDelegate2 td2 = new TestDelegate2();
        int[] iArray = {3,5,1,3,8};

        td2.TestCompareInt(TestDelegate2.SortType.Ascending, iArray);
        td2.TestCompareInt(TestDelegate2.SortType.Descending, iArray);
    }