Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ContextStack.cs
Go to the documentation of this file.
2
4
5public sealed class ContextStack
6{
8
9 public object? Current
10 {
11 get
12 {
13 if (_contextStack != null && _contextStack.Count > 0)
14 {
15 return _contextStack[_contextStack.Count - 1];
16 }
17 return null;
18 }
19 }
20
21 public object? this[int level]
22 {
23 get
24 {
25 if (level < 0)
26 {
27 throw new ArgumentOutOfRangeException("level");
28 }
29 if (_contextStack != null && level < _contextStack.Count)
30 {
31 return _contextStack[_contextStack.Count - 1 - level];
32 }
33 return null;
34 }
35 }
36
37 public object? this[Type type]
38 {
39 get
40 {
41 if (type == null)
42 {
43 throw new ArgumentNullException("type");
44 }
45 if (_contextStack != null)
46 {
47 int num = _contextStack.Count;
48 while (num > 0)
49 {
50 object obj = _contextStack[--num];
51 if (type.IsInstanceOfType(obj))
52 {
53 return obj;
54 }
55 }
56 }
57 return null;
58 }
59 }
60
61 public void Append(object context)
62 {
63 if (context == null)
64 {
65 throw new ArgumentNullException("context");
66 }
67 if (_contextStack == null)
68 {
70 }
71 _contextStack.Insert(0, context);
72 }
73
74 public object? Pop()
75 {
76 object result = null;
77 if (_contextStack != null && _contextStack.Count > 0)
78 {
79 int index = _contextStack.Count - 1;
80 result = _contextStack[index];
82 }
83 return result;
84 }
85
86 public void Push(object context)
87 {
88 if (context == null)
89 {
90 throw new ArgumentNullException("context");
91 }
92 if (_contextStack == null)
93 {
95 }
96 _contextStack.Add(context);
97 }
98}
virtual int Add(object? value)
virtual void RemoveAt(int index)
virtual void Insert(int index, object? value)