Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SendPacketsElement.cs
Go to the documentation of this file.
1using System.IO;
2
3namespace System.Net.Sockets;
4
6{
7 public string? FilePath { get; private set; }
8
9 public FileStream? FileStream { get; private set; }
10
11 public byte[]? Buffer { get; private set; }
12
13 public int Count { get; private set; }
14
15 public ReadOnlyMemory<byte>? MemoryBuffer { get; private set; }
16
17 public int Offset => checked((int)OffsetLong);
18
19 public long OffsetLong { get; private set; }
20
21 public bool EndOfPacket { get; private set; }
22
23 public SendPacketsElement(string filepath)
24 : this(filepath, 0L, 0, endOfPacket: false)
25 {
26 }
27
28 public SendPacketsElement(string filepath, int offset, int count)
29 : this(filepath, (long)offset, count, endOfPacket: false)
30 {
31 }
32
33 public SendPacketsElement(string filepath, int offset, int count, bool endOfPacket)
34 : this(filepath, (long)offset, count, endOfPacket)
35 {
36 }
37
38 public SendPacketsElement(string filepath, long offset, int count)
39 : this(filepath, offset, count, endOfPacket: false)
40 {
41 }
42
43 public SendPacketsElement(string filepath, long offset, int count, bool endOfPacket)
44 {
45 if (filepath == null)
46 {
47 throw new ArgumentNullException("filepath");
48 }
49 if (offset < 0)
50 {
51 throw new ArgumentOutOfRangeException("offset");
52 }
53 if (count < 0)
54 {
55 throw new ArgumentOutOfRangeException("count");
56 }
57 Initialize(filepath, null, null, null, offset, count, endOfPacket);
58 }
59
60 public SendPacketsElement(FileStream fileStream)
61 : this(fileStream, 0L, 0, endOfPacket: false)
62 {
63 }
64
65 public SendPacketsElement(FileStream fileStream, long offset, int count)
66 : this(fileStream, offset, count, endOfPacket: false)
67 {
68 }
69
70 public SendPacketsElement(FileStream fileStream, long offset, int count, bool endOfPacket)
71 {
72 if (fileStream == null)
73 {
74 throw new ArgumentNullException("fileStream");
75 }
76 if (!fileStream.IsAsync)
77 {
79 }
80 if (offset < 0)
81 {
82 throw new ArgumentOutOfRangeException("offset");
83 }
84 if (count < 0)
85 {
86 throw new ArgumentOutOfRangeException("count");
87 }
88 Initialize(null, fileStream, null, null, offset, count, endOfPacket);
89 }
90
92 : this(buffer, 0, (buffer != null) ? buffer.Length : 0, endOfPacket: false)
93 {
94 }
95
96 public SendPacketsElement(byte[] buffer, int offset, int count)
97 : this(buffer, offset, count, endOfPacket: false)
98 {
99 }
100
101 public SendPacketsElement(byte[] buffer, int offset, int count, bool endOfPacket)
102 {
103 if (buffer == null)
104 {
105 throw new ArgumentNullException("buffer");
106 }
107 if ((uint)offset > (uint)buffer.Length)
108 {
109 throw new ArgumentOutOfRangeException("offset");
110 }
111 if ((uint)count > (uint)(buffer.Length - offset))
112 {
113 throw new ArgumentOutOfRangeException("count");
114 }
115 Initialize(null, null, buffer, buffer.AsMemory(offset, count), offset, count, endOfPacket);
116 }
117
119 : this(buffer, endOfPacket: false)
120 {
121 }
122
124 {
125 Initialize(null, null, null, buffer, 0L, buffer.Length, endOfPacket);
126 }
127
128 private void Initialize(string filePath, FileStream fileStream, byte[] buffer, ReadOnlyMemory<byte>? memoryBuffer, long offset, int count, bool endOfPacket)
129 {
130 FilePath = filePath;
131 FileStream = fileStream;
132 Buffer = buffer;
133 MemoryBuffer = memoryBuffer;
135 Count = count;
136 EndOfPacket = endOfPacket;
137 }
138}
virtual bool IsAsync
Definition FileStream.cs:25
SendPacketsElement(ReadOnlyMemory< byte > buffer)
SendPacketsElement(byte[] buffer, int offset, int count, bool endOfPacket)
SendPacketsElement(string filepath, long offset, int count, bool endOfPacket)
void Initialize(string filePath, FileStream fileStream, byte[] buffer, ReadOnlyMemory< byte >? memoryBuffer, long offset, int count, bool endOfPacket)
SendPacketsElement(string filepath, int offset, int count, bool endOfPacket)
SendPacketsElement(FileStream fileStream, long offset, int count)
SendPacketsElement(string filepath, int offset, int count)
SendPacketsElement(FileStream fileStream, long offset, int count, bool endOfPacket)
SendPacketsElement(byte[] buffer, int offset, int count)
SendPacketsElement(ReadOnlyMemory< byte > buffer, bool endOfPacket)
SendPacketsElement(string filepath, long offset, int count)
static string net_sockets_sendpackelement_FileStreamMustBeAsync
Definition SR.cs:110
Definition SR.cs:7