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

  1. //==========================================================================
  2. //  File:       FooAssembly.cs
  3. //
  4. //  Summary:    This file demonstrates CallContext for NGWS Remoting
  5. //                       
  6. //
  7. //  Classes:    ValueObject class and SimpleObject in FooAssembly namespace
  8. //
  9. //--------------------------------------------------------------------------
  10. //  This file is part of the Microsoft NGWS Samples.
  11. //
  12. //  Copyright (C) 2000 Microsoft Corporation.  All rights reserved.
  13. //==========================================================================
  14.  
  15. using System;
  16. using System.Threading;
  17. using System.Reflection;
  18. using System.Runtime.Remoting;
  19.  
  20. namespace FooAssembly
  21. {
  22.     public class ValueObject
  23.     {
  24.         public ValueObject()
  25.         {
  26.             Console.WriteLine("ValueObject Constructor Running");
  27.         }
  28.  
  29.         public string DoWork()
  30.         {
  31.                 String z = (String) CallContext.GetData("USER");
  32.                 Console.WriteLine("USER = " + z);
  33.  
  34.             return z;
  35.         }
  36.  
  37.         ~ValueObject()
  38.         {
  39.             Console.WriteLine("ValueObject Destructor Running");
  40.         }
  41.     }
  42.  
  43.     public class SimpleObject: MarshalByRefObject
  44.     {
  45.         public SimpleObject()
  46.         {
  47.             Console.WriteLine("SimpleObject Constructor is Running ...");
  48.         }
  49.  
  50.         public string DoWork()
  51.         {
  52.             String z = (String) CallContext.GetData("USER");
  53.             Console.WriteLine("USER = " + z);
  54.  
  55.             return z;
  56.         }
  57.  
  58.         public string DoValueWork(ValueObject o)
  59.         {
  60.             Type t = o.GetType();
  61.             MethodInfo method = t.GetMethod("DoWork");
  62.             object r = method.Invoke((object) o, (object[]) null);
  63.  
  64.             return (String) r;
  65.         }
  66.  
  67.         
  68.         ~SimpleObject()
  69.         {
  70.             Console.WriteLine("SimpleObject Destructor Running");
  71.         }
  72.     }
  73. }
  74.