Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
GraphicsResource.cs
Go to the documentation of this file.
1using System;
5
7
8public abstract class GraphicsResource : IDisposable
9{
10 private string _localName;
11
12 private object _localTag;
13
14 private protected GraphicsDevice _parent;
15
16 internal ulong _internalHandle;
17
18 internal bool isDisposed;
19
20 private EventHandler<EventArgs> _003Cbacking_store_003EDisposing;
21
22 public bool IsDisposed
23 {
24 [return: MarshalAs(UnmanagedType.U1)]
25 get
26 {
27 return isDisposed;
28 }
29 }
30
31 public object Tag
32 {
33 get
34 {
35 ulong internalHandle = _internalHandle;
36 if (internalHandle != 0)
37 {
38 return _parent.Resources.GetCachedTag(internalHandle);
39 }
40 return _localTag;
41 }
42 set
43 {
44 ulong internalHandle = _internalHandle;
45 if (internalHandle != 0)
46 {
47 _parent.Resources.SetCachedTag(internalHandle, value);
48 }
49 else
50 {
52 }
53 }
54 }
55
56 public string Name
57 {
58 get
59 {
60 ulong internalHandle = _internalHandle;
61 if (internalHandle != 0)
62 {
63 return _parent.Resources.GetCachedName(internalHandle);
64 }
65 return _localName;
66 }
67 set
68 {
69 ulong internalHandle = _internalHandle;
70 if (internalHandle != 0)
71 {
72 _parent.Resources.SetCachedName(internalHandle, value);
73 }
74 else
75 {
77 }
78 }
79 }
80
82
83 [SpecialName]
84 public event EventHandler<EventArgs> Disposing
85 {
86 [MethodImpl(MethodImplOptions.Synchronized)]
87 add
88 {
90 }
91 [MethodImpl(MethodImplOptions.Synchronized)]
92 remove
93 {
95 }
96 }
97
99 {
100 }
101
102 public override string ToString()
103 {
104 ulong internalHandle = _internalHandle;
105 string text = ((internalHandle == 0) ? _localName : _parent.Resources.GetCachedName(internalHandle));
106 if (!string.IsNullOrEmpty(text))
107 {
108 return text;
109 }
110 return base.ToString();
111 }
112
113 [SpecialName]
114 protected void raise_Disposing(object value0, EventArgs value1)
115 {
116 _003Cbacking_store_003EDisposing?.Invoke(value0, value1);
117 }
118
120 {
121 isDisposed = true;
122 }
123
125 {
126 if (!isDisposed)
127 {
129 EventArgs empty = EventArgs.Empty;
130 _003Cbacking_store_003EDisposing?.Invoke(this, empty);
131 }
132 }
133
134 [HandleProcessCorruptedStateExceptions]
135 protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
136 {
137 if (P_0)
138 {
140 return;
141 }
142 try
143 {
145 }
146 finally
147 {
148 base.Finalize();
149 }
150 }
151
152 public virtual sealed void Dispose()
153 {
154 Dispose(true);
155 GC.SuppressFinalize(this);
156 }
157
159 {
160 Dispose(false);
161 }
162}
void raise_Disposing(object value0, EventArgs value1)
virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static readonly EventArgs Empty
Definition EventArgs.cs:9
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8