home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================
- // File: FooAssembly.cs
- //
- // Summary: This file demonstrates CallContext for NGWS Remoting
- //
- //
- // Classes: ValueObject class and SimpleObject in FooAssembly namespace
- //
- //--------------------------------------------------------------------------
- // This file is part of the Microsoft NGWS Samples.
- //
- // Copyright (C) 2000 Microsoft Corporation. All rights reserved.
- //==========================================================================
-
- using System;
- using System.Threading;
- using System.Reflection;
- using System.Runtime.Remoting;
-
- namespace FooAssembly
- {
- public class ValueObject
- {
- public ValueObject()
- {
- Console.WriteLine("ValueObject Constructor Running");
- }
-
- public string DoWork()
- {
- String z = (String) CallContext.GetData("USER");
- Console.WriteLine("USER = " + z);
-
- return z;
- }
-
- ~ValueObject()
- {
- Console.WriteLine("ValueObject Destructor Running");
- }
- }
-
- public class SimpleObject: MarshalByRefObject
- {
- public SimpleObject()
- {
- Console.WriteLine("SimpleObject Constructor is Running ...");
- }
-
- public string DoWork()
- {
- String z = (String) CallContext.GetData("USER");
- Console.WriteLine("USER = " + z);
-
- return z;
- }
-
- public string DoValueWork(ValueObject o)
- {
- Type t = o.GetType();
- MethodInfo method = t.GetMethod("DoWork");
- object r = method.Invoke((object) o, (object[]) null);
-
- return (String) r;
- }
-
-
- ~SimpleObject()
- {
- Console.WriteLine("SimpleObject Destructor Running");
- }
- }
- }
-