Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteConstant() [1/2]

static void System.Reflection.Metadata.BlobWriterImpl.WriteConstant ( BlobBuilder writer,
object? value )
inlinestaticpackage

Definition at line 196 of file BlobWriterImpl.cs.

197 {
198 if (value == null)
199 {
200 writer.WriteUInt32(0u);
201 return;
202 }
203 Type type = value.GetType();
204 if (type.GetTypeInfo().IsEnum)
205 {
206 type = Enum.GetUnderlyingType(type);
207 }
208 if (type == typeof(bool))
209 {
210 writer.WriteBoolean((bool)value);
211 return;
212 }
213 if (type == typeof(int))
214 {
215 writer.WriteInt32((int)value);
216 return;
217 }
218 if (type == typeof(string))
219 {
220 writer.WriteUTF16((string)value);
221 return;
222 }
223 if (type == typeof(byte))
224 {
225 writer.WriteByte((byte)value);
226 return;
227 }
228 if (type == typeof(char))
229 {
230 writer.WriteUInt16((char)value);
231 return;
232 }
233 if (type == typeof(double))
234 {
235 writer.WriteDouble((double)value);
236 return;
237 }
238 if (type == typeof(short))
239 {
240 writer.WriteInt16((short)value);
241 return;
242 }
243 if (type == typeof(long))
244 {
245 writer.WriteInt64((long)value);
246 return;
247 }
248 if (type == typeof(sbyte))
249 {
250 writer.WriteSByte((sbyte)value);
251 return;
252 }
253 if (type == typeof(float))
254 {
255 writer.WriteSingle((float)value);
256 return;
257 }
258 if (type == typeof(ushort))
259 {
260 writer.WriteUInt16((ushort)value);
261 return;
262 }
263 if (type == typeof(uint))
264 {
265 writer.WriteUInt32((uint)value);
266 return;
267 }
268 if (type == typeof(ulong))
269 {
270 writer.WriteUInt64((ulong)value);
271 return;
272 }
274 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidConstantValueOfType
Definition SR.cs:130
Definition SR.cs:7

References System.SR.Format(), System.Type.GetType(), System.Enum.GetUnderlyingType(), System.SR.InvalidConstantValueOfType, System.type, System.value, and System.writer.