home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / client_cs_17________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2002-01-21  |  3.0 KB  |  93 lines

  1. /*=====================================================================
  2.  
  3.   File:      client.cs
  4.  
  5. ---------------------------------------------------------------------
  6. This file is part of the Microsoft .NET Framework SDK Code Samples.
  7.  
  8.   Copyright (C) Microsoft Corporation.  All rights reserved.
  9.  
  10. This source code is intended only as a supplement to Microsoft
  11. Development Tools and/or on-line documentation.  See these other
  12. materials for detailed information regarding Microsoft code samples.
  13.  
  14. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  15. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  16. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  17. PARTICULAR PURPOSE.
  18. =====================================================================*/
  19.  
  20. using System;
  21. using System.Collections;
  22. using System.IO;
  23. using System.Runtime.Remoting;
  24.                 
  25. using CollectionLibrary;
  26.  
  27. public class Client
  28. {
  29.     public static int Main(string[] args)
  30.     {
  31.         Console.WriteLine(".NET Remoting Collection Client");
  32.         Console.WriteLine();
  33.         // Load the Http Channel from the config file
  34.         RemotingConfiguration.Configure("Client.exe.config");
  35.  
  36.         CollectionService collectionService = new CollectionService();
  37.  
  38.         Console.WriteLine("Retrieving a Collection Stack by Value");
  39.         Stack wordStack = collectionService.RetrieveStack();
  40.  
  41.         Console.WriteLine("Stack count: {0}", wordStack.Count);
  42.  
  43.         foreach(String word in wordStack)
  44.         {
  45.             Console.Write("{0} ", word);
  46.         }
  47.  
  48.         Console.WriteLine();
  49.         Console.WriteLine();
  50.  
  51.         Console.WriteLine("Retrieving an ArrayList by Value");
  52.         ArrayList countryArrayList = collectionService.RetrieveArrayList();
  53.  
  54.         Console.WriteLine("ArrayList count: {0}", countryArrayList.Count);
  55.  
  56.         Console.WriteLine("Country\t Capital");
  57.         Console.WriteLine("-------\t -------");
  58.         foreach(Country country in countryArrayList)
  59.         {
  60.             Console.WriteLine("{0}\t{1}",country.Name, country.Capital);
  61.         }
  62.         Console.WriteLine();
  63.  
  64.         Console.WriteLine("Retrieving Hashtable by Value");
  65.         Hashtable cityHashtable = collectionService.RetrieveHashtable();
  66.  
  67.         Console.WriteLine("Hashtable count: {0}", cityHashtable.Count);
  68.  
  69.         IDictionaryEnumerator cityEnumerator = cityHashtable.GetEnumerator();
  70.         Console.WriteLine("KEY\tVALUE");
  71.         Console.WriteLine("---\t-----");
  72.  
  73.         while ( cityEnumerator.MoveNext() )
  74.         {
  75.             Console.WriteLine( "{0}:\t{1}", cityEnumerator.Key, cityEnumerator.Value );
  76.             if (cityEnumerator.Value is City)
  77.             {
  78.                 City city = (City)cityEnumerator.Value;
  79.  
  80.                 Console.WriteLine("\t\tName    : {0}", city.Name);
  81.                 Console.WriteLine("\t\tAreaCode: {0}", city.AreaCode);
  82.             }
  83.  
  84.             Console.WriteLine();
  85.  
  86.         }
  87.         Console.WriteLine();
  88.  
  89.         return 0;
  90.     }
  91. }
  92.  
  93.