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

◆ DecimalFormatter()

System.Xml.Xsl.Runtime.DecimalFormatter.DecimalFormatter ( string formatPicture,
DecimalFormat decimalFormat )
inline

Definition at line 18 of file DecimalFormatter.cs.

19 {
20 if (formatPicture.Length == 0)
21 {
22 throw XsltException.Create(System.SR.Xslt_InvalidFormat);
23 }
24 _zeroDigit = decimalFormat.zeroDigit;
27 bool flag = true;
28 bool flag2 = false;
29 bool flag3 = false;
30 bool flag4 = false;
31 bool flag5 = false;
32 bool flag6 = false;
37 int num = 0;
38 int num2 = 0;
39 int num3 = -1;
40 int num4 = -1;
41 for (int i = 0; i < formatPicture.Length; i++)
42 {
43 char c5 = formatPicture[i];
44 if (c5 == decimalFormat.digit)
45 {
46 if (flag3 && flag)
47 {
48 throw XsltException.Create(System.SR.Xslt_InvalidFormat1, formatPicture);
49 }
50 num4 = stringBuilder.Length;
51 flag4 = (flag6 = true);
52 stringBuilder.Append('#');
53 }
54 else if (c5 == decimalFormat.zeroDigit)
55 {
56 if (flag4 && !flag)
57 {
58 throw XsltException.Create(System.SR.Xslt_InvalidFormat2, formatPicture);
59 }
60 num4 = stringBuilder.Length;
61 flag3 = (flag6 = true);
62 stringBuilder.Append('0');
63 }
64 else if (c5 == decimalFormat.patternSeparator)
65 {
66 if (!flag6)
67 {
68 throw XsltException.Create(System.SR.Xslt_InvalidFormat8);
69 }
70 if (flag2)
71 {
72 throw XsltException.Create(System.SR.Xslt_InvalidFormat3, formatPicture);
73 }
74 flag2 = true;
75 if (num3 < 0)
76 {
77 num3 = num4 + 1;
78 }
80 if (num2 > 9)
81 {
82 num2 = 0;
83 }
85 if (!flag5)
86 {
88 }
89 _posFormat = stringBuilder.ToString();
91 num3 = -1;
92 num4 = -1;
93 num = 0;
94 flag4 = (flag3 = (flag6 = false));
95 flag5 = false;
96 flag = true;
98 _negFormatInfo.NegativeSign = string.Empty;
99 }
100 else if (c5 == c)
101 {
102 if (flag5)
103 {
104 throw XsltException.Create(System.SR.Xslt_InvalidFormat5, formatPicture);
105 }
106 num3 = stringBuilder.Length;
107 flag5 = true;
108 flag4 = (flag3 = (flag = false));
109 stringBuilder.Append('.');
110 }
111 else if (c5 == c2)
112 {
113 num = stringBuilder.Length;
114 num4 = num;
115 stringBuilder.Append(',');
116 }
117 else if (c5 == c3)
118 {
119 stringBuilder.Append('%');
120 }
121 else if (c5 == c4)
122 {
123 stringBuilder.Append('‰');
124 }
125 else if (c5 == '\'')
126 {
127 int num5 = formatPicture.IndexOf('\'', i + 1);
128 if (num5 < 0)
129 {
131 }
132 stringBuilder.Append(formatPicture, i, num5 - i + 1);
133 i = num5;
134 }
135 else
136 {
137 if ((('0' <= c5 && c5 <= '9') || c5 == '\a') && decimalFormat.zeroDigit != '0')
138 {
139 stringBuilder.Append('\a');
140 }
141 if ("0#.,%‰Ee\\'\";".Contains(c5))
142 {
143 stringBuilder.Append('\\');
144 }
145 stringBuilder.Append(c5);
146 }
147 }
148 if (!flag6)
149 {
150 throw XsltException.Create(System.SR.Xslt_InvalidFormat8);
151 }
153 if (num3 < 0)
154 {
155 num3 = num4 + 1;
156 }
158 if (num2 > 9)
159 {
160 num2 = 0;
161 }
163 if (!flag5)
164 {
166 }
167 if (flag2)
168 {
169 _negFormat = stringBuilder.ToString();
170 }
171 else
172 {
173 _posFormat = stringBuilder.ToString();
174 }
175 }
static string Xslt_InvalidFormat8
Definition SR.cs:2114
static string Xslt_InvalidFormat
Definition SR.cs:2104
static string Xslt_InvalidFormat2
Definition SR.cs:2108
static string Xslt_InvalidFormat5
Definition SR.cs:2112
static string Xslt_InvalidFormat3
Definition SR.cs:2110
static string Xslt_InvalidFormat1
Definition SR.cs:2106
Definition SR.cs:7
readonly NumberFormatInfo _negFormatInfo
readonly NumberFormatInfo _posFormatInfo
static int RemoveTrailingComma(StringBuilder builder, int commaIndex, int decimalIndex)

References System.Xml.Xsl.Runtime.DecimalFormatter._negFormat, System.Xml.Xsl.Runtime.DecimalFormatter._negFormatInfo, System.Xml.Xsl.Runtime.DecimalFormatter._posFormat, System.Xml.Xsl.Runtime.DecimalFormatter._posFormatInfo, System.Xml.Xsl.Runtime.DecimalFormatter._zeroDigit, System.Globalization.NumberFormatInfo.Clone(), System.Xml.Xsl.XsltException.Create(), System.Xml.Dictionary, System.Globalization.NumberFormatInfo.NumberDecimalSeparator, System.Globalization.NumberFormatInfo.NumberGroupSeparator, System.Globalization.NumberFormatInfo.PercentSymbol, System.Globalization.NumberFormatInfo.PerMilleSymbol, System.Xml.Xsl.Runtime.DecimalFormatter.RemoveTrailingComma(), System.SR.Xslt_InvalidFormat, System.SR.Xslt_InvalidFormat1, System.SR.Xslt_InvalidFormat2, System.SR.Xslt_InvalidFormat3, System.SR.Xslt_InvalidFormat5, and System.SR.Xslt_InvalidFormat8.

Referenced by System.Xml.Xsl.Runtime.DecimalFormatter.Format().