home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================
- // File: FooClient.cs
- //
- // Summary: This file demonstrates CallContext for NGWS Remoting
- //
- //
- // Classes: Client
- //
- //--------------------------------------------------------------------------
- // This file is part of the Microsoft NGWS Samples.
- //
- // Copyright (C) 2000 Microsoft Corporation. All rights reserved.
- //==========================================================================
-
- using System;
- using System.IO;
- using System.Reflection;
- using System.Runtime.Remoting;
- using FooAssembly;
-
- public class Client
- {
- public static int Main(string[] args)
- {
- Console.WriteLine("CallContext Remoting Sample\n");
- int ret = Initialize(args);
-
- if (ret != -1)
- {
- switch (scenario)
- {
- case 1:
- Scenario1();
- break;
- }
- }
-
- Console.WriteLine("\nEnd\n");
-
- return ret;
- }
-
- public static void Scenario1()
- {
- SimpleObject so = new SimpleObject();
-
- CallContext.SetData("USER", "billg");
-
- String o = (String) CallContext.GetData("USER");
-
- Console.WriteLine("USER is '{0}'", o);
-
- String result;
-
- result = so.DoWork();
- Console.WriteLine("The returned String is '{0}'", result);
-
- ValueObject v = new ValueObject();
- result = so.DoValueWork(v);
- Console.WriteLine("The returned String is '{0}'", result);
- }
-
- //---------------------------------------------------
- public static int scenario = 1;
-
- public static int Initialize(String[] args)
- {
- if (args.Length == 0)
- {
- RemotingServices.ConfigureRemoting("FooClient.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("-s1")==0)
- {
- scenario = 1;
- }
-
- if (args[i].CompareTo("-cfg")==0)
- {
- RemotingServices.ConfigureRemoting(args[i+1]);
- }
- }
-
- return 0;
- }
-
- public static void Usage()
- {
- Console.WriteLine("Usage: FooClient [-cfg Configfile.cfg]\n");
- Console.WriteLine("Examples : FooClient");
- Console.WriteLine("Examples : FooClient -s1 (Send and receive info in the CallContext)");
- Console.WriteLine("Examples : FooClient -s1 -cfg MyStockApp.cfg");
- }
- }
-
-