home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / Remoting / MyHello / MyHello.cs < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.4 KB  |  87 lines

  1. //==========================================================================
  2. //  File:               MyHello.cs
  3. //
  4. //  Summary:    This file illustrates NGWS Remoting 
  5. //                       
  6. //  Classes:    MyHello
  7. //
  8. //--------------------------------------------------------------------------
  9. //  This file is part of the Microsoft NGWS Samples.
  10. //
  11. //  Copyright (C) 1999 Microsoft Corporation.  All rights reserved.
  12. //==========================================================================
  13.  
  14. using System;
  15. using System.Runtime.Remoting;
  16. using HelloService;
  17.  
  18. public class MyHello
  19. {
  20.     public static void Main(String[] args)
  21.     {
  22.         int ret = Initialize(args);
  23.         Console.WriteLine("MyHello Sample\n");
  24.  
  25.         if (ret == 0)
  26.         {
  27.             String result;
  28.             // new the class
  29.             Hello hello = new Hello();
  30.  
  31.             Console.Write("Enter your name: ");
  32.             String name = Console.ReadLine();
  33.  
  34.             // Call method with Name from INPUT
  35.             Console.WriteLine("Calling Hello.HelloMethod with: {0} ", name);
  36.             result = hello.HelloMethod(name);
  37.             Console.WriteLine("Hello.HelloMethod returned: {0}", result);
  38.  
  39.             Console.WriteLine("\nEnd\n");
  40.         }
  41.     }
  42.  
  43.     //---------------------------------------------------
  44.     public static int Initialize(String[] args)
  45.     {
  46.         if (args.Length == 0)
  47.         {
  48.             RemotingServices.ConfigureRemoting("MyHello.cfg");
  49.             return 0;
  50.         }
  51.  
  52.         for (int i=0;i<args.Length;i++)
  53.         {
  54.             if (
  55.                String.Compare(args[i],"HELP", true) == 0 ||
  56.                String.Compare(args[i],"?", true) == 0 ||
  57.                String.Compare(args[i],"/h", true) == 0 ||
  58.                String.Compare(args[i],"-h", true) == 0 ||
  59.                String.Compare(args[i],"-?", true) == 0 ||
  60.                String.Compare(args[i],"/?", true) == 0
  61.                )
  62.             {
  63.                 Usage();
  64.                 return -1;
  65.             }
  66.  
  67.             if (args[i].CompareTo("-cfg")==0)
  68.             {
  69.                 RemotingServices.ConfigureRemoting(args[i+1]);
  70.             }
  71.         }
  72.  
  73.         return 0;
  74.     }
  75.  
  76.     public static void Usage()
  77.     {
  78.         Console.WriteLine("Usage: MyHello [-cfg Configfile.cfg]\n");
  79.         Console.WriteLine("Examples : MyHello");
  80.         Console.WriteLine("Examples : MyHello-cfg MyHello.cfg");
  81.     }
  82. }
  83.  
  84.  
  85.  
  86.  
  87.