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

◆ WriteConstant() [2/2]

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

Definition at line 116 of file BlobWriterImpl.cs.

117 {
118 if (value == null)
119 {
120 writer.WriteUInt32(0u);
121 return;
122 }
123 Type type = value.GetType();
124 if (type.GetTypeInfo().IsEnum)
125 {
126 type = Enum.GetUnderlyingType(type);
127 }
128 if (type == typeof(bool))
129 {
130 writer.WriteBoolean((bool)value);
131 return;
132 }
133 if (type == typeof(int))
134 {
135 writer.WriteInt32((int)value);
136 return;
137 }
138 if (type == typeof(string))
139 {
140 writer.WriteUTF16((string)value);
141 return;
142 }
143 if (type == typeof(byte))
144 {
145 writer.WriteByte((byte)value);
146 return;
147 }
148 if (type == typeof(char))
149 {
150 writer.WriteUInt16((char)value);
151 return;
152 }
153 if (type == typeof(double))
154 {
155 writer.WriteDouble((double)value);
156 return;
157 }
158 if (type == typeof(short))
159 {
160 writer.WriteInt16((short)value);
161 return;
162 }
163 if (type == typeof(long))
164 {
165 writer.WriteInt64((long)value);
166 return;
167 }
168 if (type == typeof(sbyte))
169 {
170 writer.WriteSByte((sbyte)value);
171 return;
172 }
173 if (type == typeof(float))
174 {
175 writer.WriteSingle((float)value);
176 return;
177 }
178 if (type == typeof(ushort))
179 {
180 writer.WriteUInt16((ushort)value);
181 return;
182 }
183 if (type == typeof(uint))
184 {
185 writer.WriteUInt32((uint)value);
186 return;
187 }
188 if (type == typeof(ulong))
189 {
190 writer.WriteUInt64((ulong)value);
191 return;
192 }
194 }
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.

Referenced by System.Reflection.Metadata.BlobBuilder.WriteConstant(), and System.Reflection.Metadata.BlobWriter.WriteConstant().