Пример #1
0
        public void TestMethod3()
        {
            var source = @"
 [
  [""Jack Smith"",""22.33.44.55:6666""],
  [""John Doe"",""22.33.44.11:6666""]
  ]			
			
			"            ;

            var a = new List <Info>();

            JSONDocument.ParseMatrix(source,
                                     delegate
            {
                var n = new Info();

                a.Add(n);

                return(new JSONDocument.ParseArguments[]
                {
                    (JSONDocument.StringAction)(Name => n.Name = Name),
                    (JSONDocument.StringAction)(Target => n.Target = Target)
                });
            }
                                     );

            foreach (var k in a)
            {
                Console.WriteLine(new { k.Name, k.Target });
            }
        }
Пример #2
0
        public void TestMethod4()
        {
            var source = @"
 [
  [""Jack Smith"",""22.33.44.55:6666""],
  [""John Doe"",""22.33.44.11:6666""]
  ]			
			
			"            ;

            var a = new List <Info>();

            JSONDocument.ParseMatrix(source,
                                     delegate
            {
                var n = new Info();

                a.Add(n);

                return(new JSONDocument.ParseArguments[]
                {
                    (JSONDocument.StringAction)(Name => n.Name = Name),
                    (JSONDocument.StringAction)(Target => n.Target = Target)
                });
            }
                                     );

            foreach (var k in a)
            {
                Console.WriteLine(new { k.Name, k.Target });
            }

            // talk about dynamic contexts... :)
            Console.WriteLine(
                JSONDocument.ToString(
                    delegate
            {
                var i = -1;

                return(delegate
                {
                    i++;

                    if (i < a.Count)
                    {
                        var c = a[i];

                        return new[] { c.Name, c.Target };
                    }

                    return null;
                });
            }
                    )
                );
        }
Пример #3
0
            public static Info2[] Parse(string source)
            {
                var a = new ArrayList();

                JSONDocument.ParseMatrix(source,
                                         delegate
                {
                    var n = new Info2();

                    a.Add(n);

                    return(new JSONDocument.ParseArguments[]
                    {
                        (JSONDocument.StringAction)(Name => n.Name = Name),
                        (JSONDocument.StringAction)(Target => n.Target = Target)
                    });
                }
                                         );

                return((Info2[])a.ToArray(typeof(Info2)));
            }