2004-04-20 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Activation / RemoteActivationAttribute.cs
1 //
2 // System.Runtime.Remoting.Activation.RemoteActivationAttribute.cs
3 //
4 // Author: Lluis Sanchez Gual (lluis@ideary.com)
5 //
6 // (C) 2003, Lluis Sanchez Gual
7 //
8
9 using System;
10 using System.Runtime.Remoting.Activation;
11 using System.Runtime.Remoting.Contexts;
12 using System.Collections;
13
14 namespace System.Runtime.Remoting.Activation
15 {
16         internal class RemoteActivationAttribute: Attribute, IContextAttribute
17         {
18                 // This activation attribute is used when creating a client activated
19                 // CBO in the server. This attribute will enforce the creation of
20                 // a new context, and will provide the context properties collected in
21                 // the client.
22
23                 IList _contextProperties;
24
25                 public RemoteActivationAttribute ()
26                 {
27                 }
28
29                 public RemoteActivationAttribute(IList contextProperties)
30                 {
31                         _contextProperties = contextProperties;
32                 }
33
34                 public bool IsContextOK(Context ctx, IConstructionCallMessage ctor)
35                 {
36                         // CBOs remotely activated allways need a new context
37                         return false;
38                 }
39
40                 public void GetPropertiesForNewContext(IConstructionCallMessage ctor)
41                 {
42                         if (_contextProperties != null)
43                         {
44                                 foreach (object prop in _contextProperties)
45                                         ctor.ContextProperties.Add (prop);
46                         }
47                 }
48         }
49 }