Mercurial > pub > bltoolkit
comparison Demo/WebServices/Client/Program.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 using System; | |
| 2 using System.Threading; | |
| 3 using System.Windows.Forms; | |
| 4 | |
| 5 namespace Demo.WebServices.Client | |
| 6 { | |
| 7 using ObjectModel; | |
| 8 using WebClient; | |
| 9 | |
| 10 class Program | |
| 11 { | |
| 12 static void Main(string[] args) | |
| 13 { | |
| 14 WebClientBase.BaseUrl = args.Length == 0? "localhost:59179": args[1]; | |
| 15 | |
| 16 foreach (var p in PersonClient.Instance.SelectAll()) | |
| 17 { | |
| 18 PrintPerson(p); | |
| 19 } | |
| 20 | |
| 21 var map = PersonClient.Instance.SelectMap(); | |
| 22 | |
| 23 foreach (var pair in map) | |
| 24 { | |
| 25 Console.WriteLine("{0}: {1} {2} ({3})", | |
| 26 pair.Key, | |
| 27 pair.Value.FirstName, | |
| 28 pair.Value.LastName, | |
| 29 pair.Value.Gender); | |
| 30 } | |
| 31 | |
| 32 // Async call to server | |
| 33 // | |
| 34 PersonClient.Instance.SelectByKey(1, PrintPerson); | |
| 35 | |
| 36 string strVal; | |
| 37 Guid guidVal; | |
| 38 var intVal = PersonClient.Instance.MethodWithOutParams(out strVal, out guidVal); | |
| 39 | |
| 40 Console.WriteLine("int: {0}, str: {1}, guid: {2}", intVal, strVal, guidVal); | |
| 41 | |
| 42 PersonClient.Instance.MethodWithOutParams( | |
| 43 (i,s,g) => Console.WriteLine("[Callback] int: {0}, str: {1}, guid: {2}", i, s, g)); | |
| 44 | |
| 45 Console.WriteLine(); | |
| 46 Console.WriteLine("Press [Enter] key to continue"); | |
| 47 Console.WriteLine(); | |
| 48 | |
| 49 while (!Console.KeyAvailable) | |
| 50 { | |
| 51 Application.DoEvents(); | |
| 52 Thread.Sleep(200); | |
| 53 } | |
| 54 | |
| 55 Console.ReadKey(true); | |
| 56 } | |
| 57 | |
| 58 private static void PrintPerson(Person p) | |
| 59 { | |
| 60 Console.WriteLine("{0} {1} ({2})", p.FirstName, p.LastName, p.Gender); | |
| 61 } | |
| 62 } | |
| 63 } |
