Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Pointer.cs
Go to the documentation of this file.
3
4namespace System.Reflection;
5
6[CLSCompliant(false)]
7public sealed class Pointer : ISerializable
8{
9 private unsafe readonly void* _ptr;
10
11 private readonly Type _ptrType;
12
13 private unsafe Pointer(void* ptr, Type ptrType)
14 {
15 _ptr = ptr;
17 }
18
19 public unsafe static object Box(void* ptr, Type type)
20 {
21 if (type == null)
22 {
23 throw new ArgumentNullException("type");
24 }
25 if (!type.IsPointer)
26 {
27 throw new ArgumentException(SR.Arg_MustBePointer, "ptr");
28 }
29 if (!type.IsRuntimeImplemented())
30 {
31 throw new ArgumentException(SR.Arg_MustBeType, "ptr");
32 }
33 return new Pointer(ptr, type);
34 }
35
36 public unsafe static void* Unbox(object ptr)
37 {
38 if (!(ptr is Pointer))
39 {
40 throw new ArgumentException(SR.Arg_MustBePointer, "ptr");
41 }
42 return ((Pointer)ptr)._ptr;
43 }
44
45 public unsafe override bool Equals([NotNullWhen(true)] object? obj)
46 {
48 {
49 return _ptr == pointer._ptr;
50 }
51 return false;
52 }
53
54 public unsafe override int GetHashCode()
55 {
57 return ptr.GetHashCode();
58 }
59
64
66 {
67 return _ptrType;
68 }
69
70 internal unsafe IntPtr GetPointerValue()
71 {
72 return (IntPtr)_ptr;
73 }
74}
static unsafe void * Unbox(object ptr)
Definition Pointer.cs:36
unsafe override bool Equals([NotNullWhen(true)] object? obj)
Definition Pointer.cs:45
unsafe override int GetHashCode()
Definition Pointer.cs:54
readonly Type _ptrType
Definition Pointer.cs:11
unsafe IntPtr GetPointerValue()
Definition Pointer.cs:70
static unsafe object Box(void *ptr, Type type)
Definition Pointer.cs:19
unsafe readonly void * _ptr
Definition Pointer.cs:9
unsafe Pointer(void *ptr, Type ptrType)
Definition Pointer.cs:13
static string Arg_MustBeType
Definition SR.cs:302
static string Arg_MustBePointer
Definition SR.cs:288
Definition SR.cs:7
void GetObjectData(SerializationInfo info, StreamingContext context)
unsafe override int GetHashCode()
Definition UIntPtr.cs:111