home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================
- // File: MyHello.cs
- //
- // Summary: This file illustrates NGWS Remoting
- //
- // Classes: MyHello
- //
- //--------------------------------------------------------------------------
- // This file is part of the Microsoft NGWS Samples.
- //
- // Copyright (C) 1999 Microsoft Corporation. All rights reserved.
- //==========================================================================
-
- using System;
- using System.Runtime.Remoting;
- using HelloService;
-
- public class MyHello
- {
- public static void Main(String[] args)
- {
- int ret = Initialize(args);
- Console.WriteLine("MyHello Sample\n");
-
- if (ret == 0)
- {
- String result;
- // new the class
- Hello hello = new Hello();
-
- Console.Write("Enter your name: ");
- String name = Console.ReadLine();
-
- // Call method with Name from INPUT
- Console.WriteLine("Calling Hello.HelloMethod with: {0} ", name);
- result = hello.HelloMethod(name);
- Console.WriteLine("Hello.HelloMethod returned: {0}", result);
-
- Console.WriteLine("\nEnd\n");
- }
- }
-
- //---------------------------------------------------
- public static int Initialize(String[] args)
- {
- if (args.Length == 0)
- {
- RemotingServices.ConfigureRemoting("MyHello.cfg");
- return 0;
- }
-
- for (int i=0;i<args.Length;i++)
- {
- if (
- String.Compare(args[i],"HELP", true) == 0 ||
- String.Compare(args[i],"?", true) == 0 ||
- String.Compare(args[i],"/h", true) == 0 ||
- String.Compare(args[i],"-h", true) == 0 ||
- String.Compare(args[i],"-?", true) == 0 ||
- String.Compare(args[i],"/?", true) == 0
- )
- {
- Usage();
- return -1;
- }
-
- if (args[i].CompareTo("-cfg")==0)
- {
- RemotingServices.ConfigureRemoting(args[i+1]);
- }
- }
-
- return 0;
- }
-
- public static void Usage()
- {
- Console.WriteLine("Usage: MyHello [-cfg Configfile.cfg]\n");
- Console.WriteLine("Examples : MyHello");
- Console.WriteLine("Examples : MyHello-cfg MyHello.cfg");
- }
- }
-
-
-
-
-