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

◆ Create() [2/2]

static XmlCollation System.Xml.Xsl.Runtime.XmlCollation.Create ( string collationLiteral,
bool throwOnError )
inlinestaticpackage

Definition at line 114 of file XmlCollation.cs.

115 {
116 if (collationLiteral == "http://www.w3.org/2004/10/xpath-functions/collation/codepoint")
117 {
118 return CodePointCollation;
119 }
121 Options options = default(Options);
122 Uri result;
123 if (throwOnError)
124 {
125 result = new Uri(collationLiteral);
126 }
127 else if (!Uri.TryCreate(collationLiteral, UriKind.Absolute, out result))
128 {
129 return null;
130 }
131 string components = result.GetComponents(UriComponents.SchemeAndServer | UriComponents.UserInfo, UriFormat.UriEscaped);
132 if (components == "http://collations.microsoft.com")
133 {
134 string text = result.LocalPath.Substring(1);
135 if (text.Length != 0)
136 {
137 try
138 {
140 }
141 catch (ArgumentException)
142 {
143 if (!throwOnError)
144 {
145 return null;
146 }
147 throw new XslTransformException(System.SR.Coll_UnsupportedLanguage, text);
148 }
149 }
150 }
151 else
152 {
153 if (!result.IsBaseOf(new Uri("http://www.w3.org/2004/10/xpath-functions/collation/codepoint")))
154 {
155 if (!throwOnError)
156 {
157 return null;
158 }
159 throw new XslTransformException(System.SR.Coll_Unsupported, collationLiteral);
160 }
162 }
163 string query = result.Query;
164 string text2 = null;
165 if (query.Length != 0)
166 {
167 string[] array = query.Substring(1).Split('&');
168 foreach (string text3 in array)
169 {
170 string[] array2 = text3.Split('=');
171 if (array2.Length != 2)
172 {
173 if (!throwOnError)
174 {
175 return null;
176 }
177 throw new XslTransformException(System.SR.Coll_BadOptFormat, text3);
178 }
179 string text4 = array2[0].ToUpperInvariant();
180 string text5 = array2[1].ToUpperInvariant();
181 if (text4 == "SORT")
182 {
183 text2 = text5;
184 continue;
185 }
186 int flag;
187 switch (text4)
188 {
189 case "IGNORECASE":
190 flag = 1;
191 break;
192 case "IGNORENONSPACE":
193 flag = 2;
194 break;
195 case "IGNORESYMBOLS":
196 flag = 4;
197 break;
198 case "IGNOREKANATYPE":
199 flag = 8;
200 break;
201 case "IGNOREWIDTH":
202 flag = 16;
203 break;
204 case "UPPERFIRST":
205 flag = 4096;
206 break;
207 case "EMPTYGREATEST":
208 flag = 8192;
209 break;
210 case "DESCENDINGORDER":
211 flag = 16384;
212 break;
213 default:
214 if (!throwOnError)
215 {
216 return null;
217 }
218 throw new XslTransformException(System.SR.Coll_UnsupportedOpt, array2[0]);
219 }
220 switch (text5)
221 {
222 case "0":
223 case "FALSE":
224 options.SetFlag(flag, value: false);
225 continue;
226 case "1":
227 case "TRUE":
228 options.SetFlag(flag, value: true);
229 continue;
230 }
231 if (!throwOnError)
232 {
233 return null;
234 }
235 throw new XslTransformException(System.SR.Coll_UnsupportedOptVal, array2[0], array2[1]);
236 }
237 }
238 if (options.UpperFirst && options.IgnoreCase)
239 {
240 options.UpperFirst = false;
241 }
242 if (options.Ordinal)
243 {
245 options.UpperFirst = false;
246 }
247 if (text2 != null && cultureInfo != null)
248 {
249 string name = cultureInfo.Name;
250 switch (text2)
251 {
252 case "bopo":
253 if (name == "zh-TW")
254 {
255 cultureInfo = new CultureInfo("zh-TW_pronun");
256 }
257 break;
258 case "strk":
259 switch (name)
260 {
261 case "zh-CN":
262 case "zh-HK":
263 case "zh-SG":
264 case "zh-MO":
265 cultureInfo = new CultureInfo(name);
266 break;
267 }
268 break;
269 case "uni":
270 if (name == "ja-JP" || name == "ko-KR")
271 {
272 cultureInfo = new CultureInfo(name);
273 }
274 break;
275 case "phn":
276 if (name == "de-DE")
277 {
278 cultureInfo = new CultureInfo("de-DE_phoneb");
279 }
280 break;
281 case "tech":
282 if (name == "hu-HU")
283 {
284 cultureInfo = new CultureInfo("hu-HU_technl");
285 }
286 break;
287 case "mod":
288 if (name == "ka-GE")
289 {
290 cultureInfo = new CultureInfo("ka-GE_modern");
291 }
292 break;
293 default:
294 if (!throwOnError)
295 {
296 return null;
297 }
298 throw new XslTransformException(System.SR.Coll_UnsupportedSortOpt, text2);
299 case "pron":
300 case "dict":
301 case "trad":
302 break;
303 }
304 }
305 return new XmlCollation(cultureInfo, options);
306 }
static string Coll_UnsupportedOpt
Definition SR.cs:2022
static string Coll_UnsupportedOptVal
Definition SR.cs:2024
static string Coll_Unsupported
Definition SR.cs:2018
static string Coll_UnsupportedLanguage
Definition SR.cs:2020
static string Coll_UnsupportedSortOpt
Definition SR.cs:2026
static string Coll_BadOptFormat
Definition SR.cs:2016
Definition SR.cs:7
static XmlCollation CodePointCollation
XmlCollation(CultureInfo cultureInfo, Options options)
UriKind
Definition UriKind.cs:4
UriFormat
Definition UriFormat.cs:4

References System.Xml.Xsl.Runtime.XmlCollation.XmlCollation(), System.array, System.Xml.Xsl.Runtime.XmlCollation.CodePointCollation, System.SR.Coll_BadOptFormat, System.SR.Coll_Unsupported, System.SR.Coll_UnsupportedLanguage, System.SR.Coll_UnsupportedOpt, System.SR.Coll_UnsupportedOptVal, System.SR.Coll_UnsupportedSortOpt, System.Xml.Dictionary, System.Uri.GetComponents(), System.Uri.IsBaseOf(), System.Uri.LocalPath, System.options, System.Uri.Query, System.text, System.Uri.TryCreate(), and System.value.