Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NumberFormatInfo.cs
Go to the documentation of this file.
2
4{
5 private static volatile NumberFormatInfo s_invariantInfo;
6
7 internal int[] _numberGroupSizes = new int[1] { 3 };
8
9 internal int[] _currencyGroupSizes = new int[1] { 3 };
10
11 internal int[] _percentGroupSizes = new int[1] { 3 };
12
13 internal string _positiveSign = "+";
14
15 internal string _negativeSign = "-";
16
17 internal string _numberDecimalSeparator = ".";
18
19 internal string _numberGroupSeparator = ",";
20
21 internal string _currencyGroupSeparator = ",";
22
23 internal string _currencyDecimalSeparator = ".";
24
25 internal string _currencySymbol = "¤";
26
27 internal string _nanSymbol = "NaN";
28
29 internal string _positiveInfinitySymbol = "Infinity";
30
31 internal string _negativeInfinitySymbol = "-Infinity";
32
33 internal string _percentDecimalSeparator = ".";
34
35 internal string _percentGroupSeparator = ",";
36
37 internal string _percentSymbol = "%";
38
39 internal string _perMilleSymbol = "‰";
40
41 internal string[] _nativeDigits = new string[10] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
42
43 internal int _numberDecimalDigits = 2;
44
45 internal int _currencyDecimalDigits = 2;
46
48
50
51 internal int _numberNegativePattern = 1;
52
54
56
57 internal int _percentDecimalDigits = 2;
58
59 internal int _digitSubstitution = 1;
60
61 internal bool _isReadOnly;
62
63 private bool _hasInvariantNumberSigns = true;
64
66
68
70
72 {
73 get
74 {
75 object obj = s_invariantInfo;
76 if (obj == null)
77 {
79 {
80 _isReadOnly = true
81 };
83 }
84 return (NumberFormatInfo)obj;
85 }
86 }
87
89 {
90 get
91 {
93 }
94 set
95 {
96 if (value < 0 || value > 99)
97 {
99 }
102 }
103 }
104
106 {
107 get
108 {
110 }
111 set
112 {
116 }
117 }
118
119 public bool IsReadOnly => _isReadOnly;
120
122 {
123 get
124 {
125 return (int[])_currencyGroupSizes.Clone();
126 }
127 set
128 {
129 if (value == null)
130 {
131 throw new ArgumentNullException("value");
132 }
134 int[] array = (int[])value.Clone();
135 CheckGroupSize("value", array);
137 }
138 }
139
140 public int[] NumberGroupSizes
141 {
142 get
143 {
144 return (int[])_numberGroupSizes.Clone();
145 }
146 set
147 {
148 if (value == null)
149 {
150 throw new ArgumentNullException("value");
151 }
153 int[] array = (int[])value.Clone();
154 CheckGroupSize("value", array);
156 }
157 }
158
159 public int[] PercentGroupSizes
160 {
161 get
162 {
163 return (int[])_percentGroupSizes.Clone();
164 }
165 set
166 {
167 if (value == null)
168 {
169 throw new ArgumentNullException("value");
170 }
172 int[] array = (int[])value.Clone();
173 CheckGroupSize("value", array);
175 }
176 }
177
179 {
180 get
181 {
183 }
184 set
185 {
187 VerifyGroupSeparator(value, "value");
189 }
190 }
191
192 public string CurrencySymbol
193 {
194 get
195 {
196 return _currencySymbol;
197 }
198 set
199 {
200 if (value == null)
201 {
202 throw new ArgumentNullException("value");
203 }
206 }
207 }
208
210 {
211 get
212 {
213 CultureInfo currentCulture = CultureInfo.CurrentCulture;
214 if (!currentCulture._isInherited)
215 {
216 NumberFormatInfo numInfo = currentCulture._numInfo;
217 if (numInfo != null)
218 {
219 return numInfo;
220 }
221 }
222 return (NumberFormatInfo)currentCulture.GetFormat(typeof(NumberFormatInfo));
223 }
224 }
225
226 public string NaNSymbol
227 {
228 get
229 {
230 return _nanSymbol;
231 }
232 set
233 {
234 if (value == null)
235 {
236 throw new ArgumentNullException("value");
237 }
240 }
241 }
242
244 {
245 get
246 {
248 }
249 set
250 {
251 if (value < 0 || value > 15)
252 {
254 }
257 }
258 }
259
261 {
262 get
263 {
265 }
266 set
267 {
268 if (value < 0 || value > 4)
269 {
271 }
274 }
275 }
276
278 {
279 get
280 {
282 }
283 set
284 {
285 if (value < 0 || value > 3)
286 {
288 }
291 }
292 }
293
295 {
296 get
297 {
299 }
300 set
301 {
302 if (value < 0 || value > 11)
303 {
305 }
308 }
309 }
310
312 {
313 get
314 {
316 }
317 set
318 {
319 if (value == null)
320 {
321 throw new ArgumentNullException("value");
322 }
325 }
326 }
327
328 public string NegativeSign
329 {
330 get
331 {
332 return _negativeSign;
333 }
334 set
335 {
336 if (value == null)
337 {
338 throw new ArgumentNullException("value");
339 }
343 }
344 }
345
347 {
348 get
349 {
351 }
352 set
353 {
354 if (value < 0 || value > 99)
355 {
357 }
360 }
361 }
362
364 {
365 get
366 {
368 }
369 set
370 {
374 }
375 }
376
378 {
379 get
380 {
382 }
383 set
384 {
386 VerifyGroupSeparator(value, "value");
388 }
389 }
390
392 {
393 get
394 {
396 }
397 set
398 {
399 if (value < 0 || value > 3)
400 {
402 }
405 }
406 }
407
409 {
410 get
411 {
413 }
414 set
415 {
416 if (value == null)
417 {
418 throw new ArgumentNullException("value");
419 }
422 }
423 }
424
425 public string PositiveSign
426 {
427 get
428 {
429 return _positiveSign;
430 }
431 set
432 {
433 if (value == null)
434 {
435 throw new ArgumentNullException("value");
436 }
440 }
441 }
442
444 {
445 get
446 {
448 }
449 set
450 {
451 if (value < 0 || value > 99)
452 {
454 }
457 }
458 }
459
461 {
462 get
463 {
465 }
466 set
467 {
471 }
472 }
473
475 {
476 get
477 {
479 }
480 set
481 {
483 VerifyGroupSeparator(value, "value");
485 }
486 }
487
488 public string PercentSymbol
489 {
490 get
491 {
492 return _percentSymbol;
493 }
494 set
495 {
496 if (value == null)
497 {
498 throw new ArgumentNullException("value");
499 }
502 }
503 }
504
505 public string PerMilleSymbol
506 {
507 get
508 {
509 return _perMilleSymbol;
510 }
511 set
512 {
513 if (value == null)
514 {
515 throw new ArgumentNullException("value");
516 }
519 }
520 }
521
522 public string[] NativeDigits
523 {
524 get
525 {
526 return (string[])_nativeDigits.Clone();
527 }
528 set
529 {
531 VerifyNativeDigits(value, "value");
533 }
534 }
535
537 {
538 get
539 {
541 }
542 set
543 {
547 }
548 }
549
551 {
552 }
553
554 private static void VerifyDecimalSeparator(string decSep, string propertyName)
555 {
556 if (decSep == null)
557 {
558 throw new ArgumentNullException(propertyName);
559 }
560 if (decSep.Length == 0)
561 {
562 throw new ArgumentException(SR.Argument_EmptyDecString, propertyName);
563 }
564 }
565
566 private static void VerifyGroupSeparator(string groupSep, string propertyName)
567 {
568 if (groupSep == null)
569 {
570 throw new ArgumentNullException(propertyName);
571 }
572 }
573
574 private static void VerifyNativeDigits(string[] nativeDig, string propertyName)
575 {
576 if (nativeDig == null)
577 {
578 throw new ArgumentNullException(propertyName, SR.ArgumentNull_Array);
579 }
580 if (nativeDig.Length != 10)
581 {
583 }
584 for (int i = 0; i < nativeDig.Length; i++)
585 {
586 if (nativeDig[i] == null)
587 {
588 throw new ArgumentNullException(propertyName, SR.ArgumentNull_ArrayValue);
589 }
590 if (nativeDig[i].Length != 1)
591 {
592 if (nativeDig[i].Length != 2)
593 {
595 }
596 if (!char.IsSurrogatePair(nativeDig[i][0], nativeDig[i][1]))
597 {
599 }
600 }
601 if (CharUnicodeInfo.GetDecimalDigitValue(nativeDig[i], 0) != i && CharUnicodeInfo.GetUnicodeCategory(nativeDig[i], 0) != UnicodeCategory.PrivateUse)
602 {
604 }
605 }
606 }
607
608 private static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName)
609 {
610 if ((uint)digitSub > 2u)
611 {
613 }
614 }
615
617 {
619 bool flag = _negativeSign.Length == 1;
620 bool flag2 = flag;
621 if (flag2)
622 {
623 bool flag3;
624 switch (_negativeSign[0])
625 {
626 case '‒':
627 case '⁻':
628 case '₋':
629 case '−':
630 case '➖':
631 case '﹣':
632 case '-':
633 flag3 = true;
634 break;
635 default:
636 flag3 = false;
637 break;
638 }
639 flag2 = flag3;
640 }
642 }
643
644 internal NumberFormatInfo(CultureData cultureData)
645 {
646 if (cultureData != null)
647 {
648 cultureData.GetNFIValues(this);
650 }
651 }
652
653 private void VerifyWritable()
654 {
655 if (_isReadOnly)
656 {
658 }
659 }
660
661 public static NumberFormatInfo GetInstance(IFormatProvider? formatProvider)
662 {
663 if (formatProvider != null)
664 {
665 return GetProviderNonNull(formatProvider);
666 }
667 return CurrentInfo;
668 static NumberFormatInfo GetProviderNonNull(IFormatProvider provider)
669 {
670 if (provider is CultureInfo { _isInherited: false } cultureInfo)
671 {
672 return cultureInfo._numInfo ?? cultureInfo.NumberFormat;
673 }
674 return (provider as NumberFormatInfo) ?? (provider.GetFormat(typeof(NumberFormatInfo)) as NumberFormatInfo) ?? CurrentInfo;
675 }
676 }
677
678 public object Clone()
679 {
680 NumberFormatInfo numberFormatInfo = (NumberFormatInfo)MemberwiseClone();
681 numberFormatInfo._isReadOnly = false;
682 return numberFormatInfo;
683 }
684
685 internal static void CheckGroupSize(string propName, int[] groupSize)
686 {
687 for (int i = 0; i < groupSize.Length; i++)
688 {
689 if (groupSize[i] < 1)
690 {
691 if (i == groupSize.Length - 1 && groupSize[i] == 0)
692 {
693 break;
694 }
696 }
697 if (groupSize[i] > 9)
698 {
700 }
701 }
702 }
703
704 public object? GetFormat(Type? formatType)
705 {
706 if (!(formatType == typeof(NumberFormatInfo)))
707 {
708 return null;
709 }
710 return this;
711 }
712
714 {
715 if (nfi == null)
716 {
717 throw new ArgumentNullException("nfi");
718 }
719 if (nfi.IsReadOnly)
720 {
721 return nfi;
722 }
723 NumberFormatInfo numberFormatInfo = (NumberFormatInfo)nfi.MemberwiseClone();
724 numberFormatInfo._isReadOnly = true;
725 return numberFormatInfo;
726 }
727
728 internal static void ValidateParseStyleInteger(NumberStyles style)
729 {
730 if (((uint)style & 0xFFFFFE00u) != 0 && ((uint)style & 0xFFFFFDFCu) != 0)
731 {
732 ThrowInvalid(style);
733 }
734 static void ThrowInvalid(NumberStyles value)
735 {
736 if (((uint)value & 0xFFFFFC00u) != 0)
737 {
739 }
741 }
742 }
743
745 {
746 if (((uint)style & 0xFFFFFE00u) != 0)
747 {
748 ThrowInvalid(style);
749 }
750 static void ThrowInvalid(NumberStyles value)
751 {
752 if (((uint)value & 0xFFFFFC00u) != 0)
753 {
755 }
757 }
758 }
759}
static UnicodeCategory GetUnicodeCategory(char ch)
void GetNFIValues(NumberFormatInfo nfi)
static CultureInfo CurrentCulture
virtual ? object GetFormat(Type? formatType)
static void VerifyGroupSeparator(string groupSep, string propertyName)
NumberFormatInfo(CultureData cultureData)
static void ValidateParseStyleInteger(NumberStyles style)
static void VerifyNativeDigits(string[] nativeDig, string propertyName)
static volatile NumberFormatInfo s_invariantInfo
static void VerifyDigitSubstitution(DigitShapes digitSub, string propertyName)
static NumberFormatInfo GetInstance(IFormatProvider? formatProvider)
static void CheckGroupSize(string propName, int[] groupSize)
static NumberFormatInfo ReadOnly(NumberFormatInfo nfi)
static void ValidateParseStyleFloatingPoint(NumberStyles style)
static void VerifyDecimalSeparator(string decSep, string propertyName)
static string ArgumentOutOfRange_Range
Definition SR.cs:1096
static string Argument_InvalidNumberStyles
Definition SR.cs:720
static string Arg_InvalidHexStyle
Definition SR.cs:206
static string Argument_InvalidNativeDigitValue
Definition SR.cs:714
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentNull_Array
Definition SR.cs:24
static string Argument_EmptyDecString
Definition SR.cs:580
static string Arg_HexStyleNotSupported
Definition SR.cs:184
static string Argument_InvalidDigitSubstitution
Definition SR.cs:670
static string Argument_InvalidNativeDigitCount
Definition SR.cs:712
static string ArgumentNull_ArrayValue
Definition SR.cs:934
static string InvalidOperation_ReadOnly
Definition SR.cs:1504
static string Argument_InvalidGroupSize
Definition SR.cs:692
Definition SR.cs:7
object? GetFormat(Type? formatType)