blob: 6a923ac52b271d702ab5ff9b7a27478eac54e429 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
//
// System.Runtime.Remoting.Contexts.Context..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System.Collections;
namespace System.Runtime.Remoting.Contexts {
public class Context {
static Context default_context;
ArrayList context_properties;
int context_id;
bool frozen;
static int global_count;
static Context ()
{
default_context = new Context ();
default_context.frozen = true;
}
public Context ()
{
context_id = global_count++;
}
public static Context DefaultContext {
get {
return default_context;
}
}
public virtual int ContextID {
get {
return context_id;
}
}
public virtual IContextProperty GetProperty (string name)
{
if (context_properties == null)
return null;
foreach (IContextProperty p in context_properties)
if (p.Name == name)
return p;
return null;
}
public virtual void SetProperty (IContextProperty prop)
{
if (prop == null)
throw new ArgumentNullException ("IContextProperty");
if (this == default_context)
throw new InvalidOperationException ("Can not add properties to " +
"default context");
if (frozen)
throw new InvalidOperationException ("Context is Frozen");
if (context_properties == null)
context_properties = new ArrayList ();
context_properties.Add (prop);
}
}
}
|