Esempio n. 1
0
        private Dictionary <string, object> FixRow(List <NoteTable> res, SomeFunc fn, string tags)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            foreach (NoteTable row in res)
            {
                dict.Add("id", row.Id);
                dict.Add("t", fn(tags, row.Tags));
                dict.Add("n", DateTimeOffset.Now.ToUnixTimeSeconds());
                dict.Add("u", collection.Usn);
            }
            return(dict);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            SomeFunc <String, int> f1 =
                (x) => Int32.Parse(x);

            SomeFunc <int, bool> f2 =
                (y) => true;

            string[] input = { "123", "10", "7" };

            Converter <string, int> conv =
                (s) => Int32.Parse(s);

            int[] output =
                Array.ConvertAll(
                    input,
                    conv
                    );
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            SomeFunc sf1 = delegate(int i) {
                return(i * i);
            };
            SomeFunc sf2 = delegate(int i) {
                return(i / 2.0);
            };
            SomeFunc sf3 = delegate {
                return(1.234);
            };

            double result1 = sf1(20);
            double result2 = sf2(15);
            double result3 = sf3(2);

            Console.WriteLine("First results are: {0}, {1}, {2}", result1, result2, result3);
            useDelegates(10, sf1, sf2, sf3);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            SomeFunc sf1 = new SomeFunc(TestOne.square);
            SomeFunc sf2 = new SomeFunc(TestOne.half);

            TestTwo  t1  = new TestTwo(20);
            TestTwo  t2  = new TestTwo(15);
            SomeFunc sf3 = new SomeFunc(t1.multiply);
            SomeFunc sf4 = new SomeFunc(t2.divide);

            double result1 = sf1(20);
            double result2 = sf2(15);
            double result3 = sf3(2);
            double result4 = sf4(10);

            Console.WriteLine("First results are: {0}, {1}, {2}, {3}", result1, result2, result3, result4);

            useDelegates(10, sf1, sf2, sf3, sf4);
        }
Esempio n. 5
0
 static void PassMeDelegate(SomeFunc action)
 {
     GC.KeepAlive(action);
 }