Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RequestContextBase.cs
Go to the documentation of this file.
3
4namespace System.Net;
5
6internal abstract class RequestContextBase : IDisposable
7{
8 private unsafe global::Interop.HttpApi.HTTP_REQUEST* _memoryBlob;
9
10 private unsafe global::Interop.HttpApi.HTTP_REQUEST* _originalBlobAddress;
11
13
15
16 internal unsafe global::Interop.HttpApi.HTTP_REQUEST* RequestBlob => _memoryBlob;
17
19
20 internal uint Size => (uint)_backingBufferLength;
21
23 {
24 get
25 {
26 global::Interop.HttpApi.HTTP_REQUEST* memoryBlob = _memoryBlob;
27 return (IntPtr)((memoryBlob == null) ? _originalBlobAddress : memoryBlob);
28 }
29 }
30
31 protected unsafe void BaseConstruction(global::Interop.HttpApi.HTTP_REQUEST* requestBlob)
32 {
33 if (requestBlob != null)
34 {
35 _memoryBlob = requestBlob;
36 }
37 }
38
39 internal unsafe void ReleasePins()
40 {
42 UnsetBlob();
44 }
45
46 protected abstract void OnReleasePins();
47
48 public void Close()
49 {
50 Dispose();
51 }
52
53 public void Dispose()
54 {
55 Dispose(disposing: true);
56 GC.SuppressFinalize(this);
57 }
58
59 protected virtual void Dispose(bool disposing)
60 {
62 if (intPtr != IntPtr.Zero)
63 {
64 Marshal.FreeHGlobal(intPtr);
65 }
66 }
67
69 {
70 Dispose(disposing: false);
71 }
72
73 protected unsafe void SetBlob(global::Interop.HttpApi.HTTP_REQUEST* requestBlob)
74 {
75 if (requestBlob == null)
76 {
77 UnsetBlob();
78 }
79 else
80 {
81 _memoryBlob = requestBlob;
82 }
83 }
84
85 protected unsafe void UnsetBlob()
86 {
87 _memoryBlob = null;
88 }
89
90 protected unsafe void SetBuffer(int size)
91 {
93 {
95 }
96 _backingBuffer = ((size == 0) ? IntPtr.Zero : Marshal.AllocHGlobal(size));
99 }
100}
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
virtual void Dispose(bool disposing)
unsafe void SetBuffer(int size)
unsafe global::Interop.HttpApi.HTTP_REQUEST * RequestBlob
unsafe void BaseConstruction(global::Interop.HttpApi.HTTP_REQUEST *requestBlob)
unsafe global::Interop.HttpApi.HTTP_REQUEST * _memoryBlob
unsafe void SetBlob(global::Interop.HttpApi.HTTP_REQUEST *requestBlob)
unsafe global::Interop.HttpApi.HTTP_REQUEST * _originalBlobAddress
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625
static int Exchange(ref int location1, int value)
static readonly IntPtr Zero
Definition IntPtr.cs:18
unsafe void * ToPointer()
Definition IntPtr.cs:210
unsafe void Clear()
Definition Span.cs:198