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

◆ InternalFlagsFormat() [1/2]

static string System.Enum.InternalFlagsFormat ( EnumInfo enumInfo,
ulong resultValue )
inlinestaticprivate

Definition at line 177 of file Enum.cs.

178 {
179 string[] names = enumInfo.Names;
180 ulong[] values = enumInfo.Values;
181 if (resultValue == 0L)
182 {
183 if (values.Length == 0 || values[0] != 0L)
184 {
185 return "0";
186 }
187 return names[0];
188 }
189 Span<int> span = stackalloc int[64];
190 int num;
191 for (num = values.Length - 1; num >= 0; num--)
192 {
193 if (values[num] == resultValue)
194 {
195 return names[num];
196 }
197 if (values[num] < resultValue)
198 {
199 break;
200 }
201 }
202 int num2 = 0;
203 int num3 = 0;
204 while (num >= 0)
205 {
206 ulong num4 = values[num];
207 if (num == 0 && num4 == 0L)
208 {
209 break;
210 }
211 if ((resultValue & num4) == num4)
212 {
213 resultValue -= num4;
214 span[num3++] = num;
215 num2 = checked(num2 + names[num].Length);
216 }
217 num--;
218 }
219 if (resultValue != 0L)
220 {
221 return null;
222 }
223 string text = string.FastAllocateString(checked(num2 + 2 * (num3 - 1)));
224 Span<char> destination = new Span<char>(ref text.GetRawStringData(), text.Length);
225 string text2 = names[span[--num3]];
226 text2.CopyTo(destination);
227 destination = destination.Slice(text2.Length);
228 while (--num3 >= 0)
229 {
230 destination[0] = ',';
231 destination[1] = ' ';
232 destination = destination.Slice(2);
233 text2 = names[span[num3]];
234 text2.CopyTo(destination);
235 destination = destination.Slice(text2.Length);
236 }
237 return text;
238 }

References System.destination, System.L, System.Enum.EnumInfo.Names, System.text, System.Enum.EnumInfo.Values, and System.values.