10 [global::__DynamicallyInvokable]
13 private static XmlCharType xmlCharType = XmlCharType.Instance;
15 internal static char[] crt =
new char[3]
22 private static readonly
int c_EncodedCharLength = 7;
24 private static volatile Regex c_EncodeCharPattern;
26 private static volatile Regex c_DecodeCharPattern;
28 private static volatile string[] s_allDateTimeFormats;
30 internal static readonly
char[] WhitespaceChars =
new char[4]
38 private static string[] AllDateTimeFormats
42 if (s_allDateTimeFormats ==
null)
44 CreateAllDateTimeFormats();
46 return s_allDateTimeFormats;
53 [global::__DynamicallyInvokable]
56 return EncodeName(name, first:
true, local:
false);
62 [global::__DynamicallyInvokable]
65 return EncodeName(name, first:
false, local:
false);
71 [global::__DynamicallyInvokable]
74 return EncodeName(name, first:
true, local:
true);
80 [global::__DynamicallyInvokable]
83 if (name ==
null || name.Length == 0)
88 int length = name.Length;
90 int num2 = name.IndexOf(
'_');
95 if (c_DecodeCharPattern ==
null)
97 c_DecodeCharPattern =
new Regex(
"_[Xx]([0-9a-fA-F]{4}|[0-9a-fA-F]{8})_");
99 matchCollection = c_DecodeCharPattern.
Matches(name, num2);
102 if (enumerator !=
null && enumerator.
MoveNext())
107 for (
int i = 0; i < length - c_EncodedCharLength + 1; i++)
118 if (stringBuilder ==
null)
122 stringBuilder.
Append(name, num, i - num);
123 if (name[i + 6] !=
'_')
125 int num4 = FromHex(name[i + 2]) * 268435456 + FromHex(name[i + 3]) * 16777216 + FromHex(name[i + 4]) * 1048576 + FromHex(name[i + 5]) * 65536 + FromHex(name[i + 6]) * 4096 + FromHex(name[i + 7]) * 256 + FromHex(name[i + 8]) * 16 + FromHex(name[i + 9]);
130 num = i + c_EncodedCharLength + 4;
131 XmlCharType.SplitSurrogateChar(num4, out
char lowChar, out
char highChar);
132 stringBuilder.
Append(highChar);
133 stringBuilder.
Append(lowChar);
138 num = i + c_EncodedCharLength + 4;
139 stringBuilder.
Append((
char)num4);
141 i += c_EncodedCharLength - 1 + 4;
145 num = i + c_EncodedCharLength;
146 stringBuilder.
Append((
char)(FromHex(name[i + 2]) * 4096 + FromHex(name[i + 3]) * 256 + FromHex(name[i + 4]) * 16 + FromHex(name[i + 5])));
147 i += c_EncodedCharLength - 1;
156 stringBuilder.
Append(name, num, length - num);
163 private static string EncodeName(
string name,
bool first,
bool local)
165 if (
string.IsNullOrEmpty(name))
170 int length = name.Length;
173 int num2 = name.IndexOf(
'_');
178 if (c_EncodeCharPattern ==
null)
180 c_EncodeCharPattern =
new Regex(
"(?<=_)[Xx]([0-9a-fA-F]{4}|[0-9a-fA-F]{8})_");
182 matchCollection = c_EncodeCharPattern.
Matches(name, num2);
186 if (enumerator !=
null && enumerator.
MoveNext())
189 num3 = match.Index - 1;
191 if (first && ((!xmlCharType.IsStartNCNameCharXml4e(name[0]) && (local || (!local && name[0] !=
':'))) || num3 == 0))
193 if (stringBuilder ==
null)
197 stringBuilder.
Append(
"_x");
198 if (length > 1 && XmlCharType.IsHighSurrogate(name[0]) && XmlCharType.IsLowSurrogate(name[1]))
200 int highChar = name[0];
201 int lowChar = name[1];
211 stringBuilder.
Append(
"_");
213 if (num3 == 0 && enumerator.
MoveNext())
216 num3 = match2.
Index - 1;
219 for (; i < length; i++)
221 if ((local && !xmlCharType.IsNCNameCharXml4e(name[i])) || (!local && !xmlCharType.IsNameCharXml4e(name[i])) || num3 == i)
223 if (stringBuilder ==
null)
227 if (num3 == i && enumerator.
MoveNext())
230 num3 = match3.
Index - 1;
232 stringBuilder.
Append(name, num, i - num);
233 stringBuilder.
Append(
"_x");
234 if (length > i + 1 && XmlCharType.IsHighSurrogate(name[i]) && XmlCharType.IsLowSurrogate(name[i + 1]))
236 int highChar2 = name[i];
237 int lowChar2 = name[i + 1];
247 stringBuilder.
Append(
"_");
256 stringBuilder.
Append(name, num, length - num);
261 private static int FromHex(
char digit)
265 return ((digit <=
'F') ? (digit - 65) : (digit - 97)) + 10;
270 internal static byte[] FromBinHexString(
string s)
272 return FromBinHexString(s, allowOddCount:
true);
275 internal static byte[] FromBinHexString(
string s,
bool allowOddCount)
279 throw new ArgumentNullException(
"s");
281 return BinHexDecoder.Decode(s.ToCharArray(), allowOddCount);
284 internal static string ToBinHexString(
byte[] inArray)
288 throw new ArgumentNullException(
"inArray");
290 return BinHexEncoder.Encode(inArray, 0, inArray.Length);
300 [global::__DynamicallyInvokable]
307 if (name.Length == 0)
311 int num = ValidateNames.ParseNameNoNamespaces(name, 0);
312 if (num != name.Length)
314 throw CreateInvalidNameCharException(name, num, ExceptionType.XmlException);
319 internal static Exception TryVerifyName(
string name)
321 if (name ==
null || name.Length == 0)
325 int num = ValidateNames.ParseNameNoNamespaces(name, 0);
326 if (num != name.Length)
328 return new XmlException((num == 0) ?
"Xml_BadStartNameChar" :
"Xml_BadNameChar", XmlException.BuildCharExceptionArgs(name, num));
333 internal static string VerifyQName(
string name)
335 return VerifyQName(name, ExceptionType.XmlException);
338 internal static string VerifyQName(
string name, ExceptionType exceptionType)
340 if (name ==
null || name.Length == 0)
342 throw new ArgumentNullException(
"name");
344 int colonOffset = -1;
345 int num = ValidateNames.ParseQName(name, 0, out colonOffset);
346 if (num != name.Length)
348 throw CreateException(
"Xml_BadNameChar", XmlException.BuildCharExceptionArgs(name, num), exceptionType, 0, num + 1);
360 [global::__DynamicallyInvokable]
366 internal static string VerifyNCName(
string name, ExceptionType exceptionType)
372 if (name.Length == 0)
376 int num = ValidateNames.ParseNCName(name, 0);
377 if (num != name.Length)
379 throw CreateInvalidNameCharException(name, num, exceptionType);
384 internal static Exception TryVerifyNCName(
string name)
386 int num = ValidateNames.ParseNCName(name);
387 if (num == 0 || num != name.Length)
389 return ValidateNames.GetInvalidNameException(name, 0, num);
400 if (token ==
null || token.Length == 0)
404 if (token[0] ==
' ' || token[token.Length - 1] ==
' ' || token.IndexOfAny(crt) != -1 || token.IndexOf(
" ",
StringComparison.Ordinal) != -1)
411 internal static Exception TryVerifyTOKEN(
string token)
413 if (token ==
null || token.Length == 0)
417 if (token[0] ==
' ' || token[token.Length - 1] ==
' ' || token.IndexOfAny(crt) != -1 || token.IndexOf(
" ",
StringComparison.Ordinal) != -1)
419 return new XmlException(
"Sch_NotTokenString", token);
430 [global::__DynamicallyInvokable]
436 internal static string VerifyNMTOKEN(
string name, ExceptionType exceptionType)
442 if (name.Length == 0)
444 throw CreateException(
"Xml_InvalidNmToken", name, exceptionType);
446 int num = ValidateNames.ParseNmtokenNoNamespaces(name, 0);
447 if (num != name.Length)
449 throw CreateException(
"Xml_BadNameChar", XmlException.BuildCharExceptionArgs(name, num), exceptionType, 0, num + 1);
454 internal static Exception TryVerifyNMTOKEN(
string name)
456 if (name ==
null || name.Length == 0)
458 return new XmlException(
"Xml_EmptyName",
string.Empty);
460 int num = ValidateNames.ParseNmtokenNoNamespaces(name, 0);
461 if (num != name.Length)
463 return new XmlException(
"Xml_BadNameChar", XmlException.BuildCharExceptionArgs(name, num));
468 internal static string VerifyNormalizedString(
string str)
470 if (str.IndexOfAny(crt) != -1)
477 internal static Exception TryVerifyNormalizedString(
string str)
479 if (str.IndexOfAny(crt) != -1)
490 [global::__DynamicallyInvokable]
497 VerifyCharData(content, ExceptionType.XmlException);
505 [global::__DynamicallyInvokable]
508 if (publicId ==
null)
512 int num = xmlCharType.IsPublicId(publicId);
515 throw CreateInvalidCharException(publicId, num, ExceptionType.XmlException);
524 [global::__DynamicallyInvokable]
531 int num = xmlCharType.IsOnlyWhitespaceWithPos(content);
534 throw new XmlException(
"Xml_InvalidWhitespaceCharacter",
XmlException.BuildCharExceptionArgs(content, num), 0, num + 1);
545 return (xmlCharType.charProperties[(
int)ch] & 4) != 0;
553 return (xmlCharType.charProperties[(
int)ch] & 8) != 0;
562 return (xmlCharType.charProperties[(
int)ch] & 0x10) != 0;
572 if (XmlCharType.IsHighSurrogate(highChar))
574 return XmlCharType.IsLowSurrogate(lowChar);
585 return xmlCharType.IsPubidChar(ch);
594 return (xmlCharType.charProperties[(
int)ch] & 1) != 0;
600 [global::__DynamicallyInvokable]
613 [global::__DynamicallyInvokable]
616 return value.ToString(
null);
622 [global::__DynamicallyInvokable]
631 [CLSCompliant(
false)]
632 [global::__DynamicallyInvokable]
641 [global::__DynamicallyInvokable]
650 [global::__DynamicallyInvokable]
659 [global::__DynamicallyInvokable]
668 [global::__DynamicallyInvokable]
677 [CLSCompliant(
false)]
678 [global::__DynamicallyInvokable]
687 [CLSCompliant(
false)]
688 [global::__DynamicallyInvokable]
697 [CLSCompliant(
false)]
698 [global::__DynamicallyInvokable]
707 [global::__DynamicallyInvokable]
710 if (
float.IsNegativeInfinity(value))
714 if (
float.IsPositiveInfinity(value))
718 if (IsNegativeZero(value))
728 [global::__DynamicallyInvokable]
731 if (
double.IsNegativeInfinity(value))
735 if (
double.IsPositiveInfinity(value))
739 if (IsNegativeZero(value))
749 [global::__DynamicallyInvokable]
752 return new XsdDuration(value).ToString();
758 [Obsolete(
"Use XmlConvert.ToString() that takes in XmlDateTimeSerializationMode")]
761 return ToString(value,
"yyyy-MM-ddTHH:mm:ss.fffffffzzzzzz");
779 [global::__DynamicallyInvokable]
782 switch (dateTimeOption)
785 value = SwitchToLocalTime(value);
788 value = SwitchToUtcTime(value);
794 throw new ArgumentException(Res.GetString(
"Sch_InvalidDateTimeOption", dateTimeOption,
"dateTimeOption"));
798 return new XsdDateTime(value, XsdDateTimeFlags.DateTime).
ToString();
804 [global::__DynamicallyInvokable]
807 return new XsdDateTime(value).ToString();
814 [global::__DynamicallyInvokable]
823 [global::__DynamicallyInvokable]
826 return value.ToString();
836 [global::__DynamicallyInvokable]
849 throw new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Boolean"));
853 internal static Exception TryToBoolean(
string s, out
bool result)
868 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Boolean"));
877 [global::__DynamicallyInvokable]
886 throw new FormatException(Res.GetString(
"XmlConvert_NotOneCharString"));
891 internal static Exception TryToChar(
string s, out
char result)
893 if (!
char.TryParse(s, out result))
895 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Char"));
909 [global::__DynamicallyInvokable]
915 internal static Exception TryToDecimal(
string s, out decimal result)
919 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Decimal"));
924 internal static decimal ToInteger(
string s)
929 internal static Exception TryToInteger(
string s, out decimal result)
933 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Integer"));
947 [CLSCompliant(
false)]
948 [global::__DynamicallyInvokable]
954 internal static Exception TryToSByte(
string s, out sbyte result)
958 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"SByte"));
972 [global::__DynamicallyInvokable]
978 internal static Exception TryToInt16(
string s, out
short result)
982 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Int16"));
996 [global::__DynamicallyInvokable]
1002 internal static Exception TryToInt32(
string s, out
int result)
1006 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Int32"));
1020 [global::__DynamicallyInvokable]
1026 internal static Exception TryToInt64(
string s, out
long result)
1030 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Int64"));
1044 [global::__DynamicallyInvokable]
1050 internal static Exception TryToByte(
string s, out
byte result)
1054 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Byte"));
1068 [CLSCompliant(
false)]
1069 [global::__DynamicallyInvokable]
1075 internal static Exception TryToUInt16(
string s, out ushort result)
1079 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"UInt16"));
1093 [CLSCompliant(
false)]
1094 [global::__DynamicallyInvokable]
1100 internal static Exception TryToUInt32(
string s, out uint result)
1104 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"UInt32"));
1118 [CLSCompliant(
false)]
1119 [global::__DynamicallyInvokable]
1125 internal static Exception TryToUInt64(
string s, out ulong result)
1129 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"UInt64"));
1143 [global::__DynamicallyInvokable]
1149 return float.NegativeInfinity;
1153 return float.PositiveInfinity;
1156 if (num == 0f && s[0] ==
'-')
1163 internal static Exception TryToSingle(
string s, out
float result)
1168 result =
float.NegativeInfinity;
1173 result =
float.PositiveInfinity;
1178 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Single"));
1180 if (result == 0f && s[0] ==
'-')
1196 [global::__DynamicallyInvokable]
1202 return double.NegativeInfinity;
1206 return double.PositiveInfinity;
1209 if (num == 0.0 && s[0] ==
'-')
1216 internal static Exception TryToDouble(
string s, out
double result)
1221 result =
double.NegativeInfinity;
1226 result =
double.PositiveInfinity;
1231 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Double"));
1233 if (result == 0.0 && s[0] ==
'-')
1240 internal static double ToXPathDouble(
object o)
1242 string text = o as string;
1245 text = TrimString(text);
1268 catch (FormatException)
1271 catch (OverflowException)
1274 catch (ArgumentNullException)
1280 internal static string ToXPathString(
object value)
1282 string text = value as string;
1287 if (value is
double)
1302 internal static double XPathRound(
double value)
1304 double num = Math.Round(value);
1305 if (value - num != 0.5)
1317 [global::__DynamicallyInvokable]
1320 XsdDuration xsdDuration;
1323 xsdDuration =
new XsdDuration(s);
1327 throw new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"TimeSpan"));
1329 return xsdDuration.ToTimeSpan();
1334 XsdDuration result2;
1335 Exception ex = XsdDuration.TryParse(s, out result2);
1341 return result2.TryToTimeSpan(out result);
1344 private static void CreateAllDateTimeFormats()
1346 if (s_allDateTimeFormats ==
null)
1348 s_allDateTimeFormats =
new string[24]
1350 "yyyy-MM-ddTHH:mm:ss.FFFFFFFzzzzzz",
1351 "yyyy-MM-ddTHH:mm:ss.FFFFFFF",
1352 "yyyy-MM-ddTHH:mm:ss.FFFFFFFZ",
1354 "HH:mm:ss.FFFFFFFZ",
1355 "HH:mm:ss.FFFFFFFzzzzzz",
1385 [Obsolete(
"Use XmlConvert.ToDateTime() that takes in XmlDateTimeSerializationMode")]
1428 [global::__DynamicallyInvokable]
1431 XsdDateTime xdt =
new XsdDateTime(s, XsdDateTimeFlags.AllXsd);
1433 switch (dateTimeOption)
1436 dateTime = SwitchToLocalTime(dateTime);
1439 dateTime = SwitchToUtcTime(dateTime);
1445 throw new ArgumentException(Res.GetString(
"Sch_InvalidDateTimeOption", dateTimeOption,
"dateTimeOption"));
1460 [global::__DynamicallyInvokable]
1467 XsdDateTime xdt =
new XsdDateTime(s, XsdDateTimeFlags.AllXsd);
1479 [global::__DynamicallyInvokable]
1493 [global::__DynamicallyInvokable]
1506 [global::__DynamicallyInvokable]
1512 internal static Exception TryToGuid(
string s, out
Guid result)
1518 result =
new Guid(s);
1523 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Guid"));
1525 catch (FormatException)
1527 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Guid"));
1531 private static DateTime SwitchToLocalTime(DateTime value)
1540 return value.ToLocalTime();
1546 private static DateTime SwitchToUtcTime(DateTime value)
1555 return value.ToUniversalTime();
1561 internal static Uri ToUri(
string s)
1563 if (s !=
null && s.Length > 0)
1568 throw new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Uri"));
1571 if (!Uri.TryCreate(s,
UriKind.RelativeOrAbsolute, out Uri result))
1573 throw new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Uri"));
1578 internal static Exception TryToUri(
string s, out Uri result)
1581 if (s !=
null && s.Length > 0)
1586 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Uri"));
1589 if (!Uri.TryCreate(s,
UriKind.RelativeOrAbsolute, out result))
1591 return new FormatException(Res.GetString(
"XmlConvert_BadFormat", s,
"Uri"));
1596 internal static bool StrEqual(
char[] chars,
int strPos1,
int strLen1,
string str2)
1598 if (strLen1 != str2.Length)
1603 for (i = 0; i < strLen1 && chars[strPos1 + i] == str2[i]; i++)
1606 return i == strLen1;
1609 internal static string TrimString(
string value)
1611 return value.Trim(WhitespaceChars);
1614 internal static string TrimStringStart(
string value)
1616 return value.TrimStart(WhitespaceChars);
1619 internal static string TrimStringEnd(
string value)
1621 return value.TrimEnd(WhitespaceChars);
1624 internal static string[] SplitString(
string value)
1629 internal static string[] SplitString(
string value,
StringSplitOptions splitStringOptions)
1631 return value.Split(WhitespaceChars, splitStringOptions);
1634 internal static bool IsNegativeZero(
double value)
1636 if (value == 0.0 && DoubleToInt64Bits(value) == DoubleToInt64Bits(-0.0))
1643 private unsafe
static long DoubleToInt64Bits(
double value)
1645 return *(
long*)(&value);
1648 internal static void VerifyCharData(
string data, ExceptionType exceptionType)
1650 VerifyCharData(data, exceptionType, exceptionType);
1653 internal unsafe
static void VerifyCharData(
string data, ExceptionType invCharExceptionType, ExceptionType invSurrogateExceptionType)
1655 if (data ==
null || data.Length == 0)
1660 int length = data.Length;
1663 if (num < length && (xmlCharType.charProperties[(
int)data[num]] & 0x10) != 0)
1672 char ch = data[num];
1673 if (!XmlCharType.IsHighSurrogate(ch))
1677 if (num + 1 == length)
1679 throw CreateException(
"Xml_InvalidSurrogateMissingLowChar", invSurrogateExceptionType, 0, num + 1);
1682 if (XmlCharType.IsLowSurrogate(ch))
1687 throw CreateInvalidSurrogatePairException(data[num + 1], data[num], invSurrogateExceptionType, 0, num + 1);
1689 throw CreateInvalidCharException(data, num, invCharExceptionType);
1692 internal unsafe
static void VerifyCharData(
char[] data,
int offset,
int len, ExceptionType exceptionType)
1694 if (data ==
null || len == 0)
1699 int num2 = offset + len;
1702 if (num < num2 && (xmlCharType.charProperties[(
int)data[num]] & 0x10) != 0)
1711 char ch = data[num];
1712 if (!XmlCharType.IsHighSurrogate(ch))
1716 if (num + 1 == num2)
1718 throw CreateException(
"Xml_InvalidSurrogateMissingLowChar", exceptionType, 0, offset - num + 1);
1721 if (XmlCharType.IsLowSurrogate(ch))
1726 throw CreateInvalidSurrogatePairException(data[num + 1], data[num], exceptionType, 0, offset - num + 1);
1728 throw CreateInvalidCharException(data, len, num, exceptionType);
1731 internal static string EscapeValueForDebuggerDisplay(
string value)
1736 for (; i < value.Length; i++)
1739 if (c <
' ' || c ==
'"')
1741 if (stringBuilder ==
null)
1747 stringBuilder.
Append(value, num, i - num);
1753 stringBuilder.
Append(
"\\\"");
1756 stringBuilder.
Append(
"\\r");
1759 stringBuilder.
Append(
"\\n");
1762 stringBuilder.
Append(
"\\t");
1770 if (stringBuilder ==
null)
1776 stringBuilder.
Append(value, num, i - num);
1781 internal static Exception CreateException(
string res, ExceptionType exceptionType)
1783 return CreateException(res, exceptionType, 0, 0);
1786 internal static Exception CreateException(
string res, ExceptionType exceptionType,
int lineNo,
int linePos)
1788 switch (exceptionType)
1790 case ExceptionType.ArgumentException:
1791 return new ArgumentException(Res.GetString(res));
1793 return new XmlException(res,
string.Empty, lineNo, linePos);
1797 internal static Exception CreateException(
string res,
string arg, ExceptionType exceptionType)
1799 return CreateException(res, arg, exceptionType, 0, 0);
1802 internal static Exception CreateException(
string res,
string arg, ExceptionType exceptionType,
int lineNo,
int linePos)
1804 switch (exceptionType)
1806 case ExceptionType.ArgumentException:
1807 return new ArgumentException(Res.GetString(res, arg));
1809 return new XmlException(res, arg, lineNo, linePos);
1813 internal static Exception CreateException(
string res,
string[] args, ExceptionType exceptionType)
1815 return CreateException(res, args, exceptionType, 0, 0);
1818 internal static Exception CreateException(
string res,
string[] args, ExceptionType exceptionType,
int lineNo,
int linePos)
1820 switch (exceptionType)
1822 case ExceptionType.ArgumentException:
1823 return new ArgumentException(Res.GetString(res, args));
1825 return new XmlException(res, args, lineNo, linePos);
1829 internal static Exception CreateInvalidSurrogatePairException(
char low,
char hi)
1831 return CreateInvalidSurrogatePairException(low, hi, ExceptionType.ArgumentException);
1834 internal static Exception CreateInvalidSurrogatePairException(
char low,
char hi, ExceptionType exceptionType)
1836 return CreateInvalidSurrogatePairException(low, hi, exceptionType, 0, 0);
1839 internal static Exception CreateInvalidSurrogatePairException(
char low,
char hi, ExceptionType exceptionType,
int lineNo,
int linePos)
1841 string[] obj =
new string[2];
1846 string[] args = obj;
1847 return CreateException(
"Xml_InvalidSurrogatePairWithArgs", args, exceptionType, lineNo, linePos);
1850 internal static Exception CreateInvalidHighSurrogateCharException(
char hi)
1852 return CreateInvalidHighSurrogateCharException(hi, ExceptionType.ArgumentException);
1855 internal static Exception CreateInvalidHighSurrogateCharException(
char hi, ExceptionType exceptionType)
1857 return CreateInvalidHighSurrogateCharException(hi, exceptionType, 0, 0);
1860 internal static Exception CreateInvalidHighSurrogateCharException(
char hi, ExceptionType exceptionType,
int lineNo,
int linePos)
1863 return CreateException(
"Xml_InvalidSurrogateHighChar", num.ToString(
"X",
CultureInfo.
InvariantCulture), exceptionType, lineNo, linePos);
1866 internal static Exception CreateInvalidCharException(
char[] data,
int length,
int invCharPos)
1868 return CreateInvalidCharException(data, length, invCharPos, ExceptionType.ArgumentException);
1871 internal static Exception CreateInvalidCharException(
char[] data,
int length,
int invCharPos, ExceptionType exceptionType)
1873 return CreateException(
"Xml_InvalidCharacter", XmlException.BuildCharExceptionArgs(data, length, invCharPos), exceptionType, 0, invCharPos + 1);
1876 internal static Exception CreateInvalidCharException(
string data,
int invCharPos)
1878 return CreateInvalidCharException(data, invCharPos, ExceptionType.ArgumentException);
1881 internal static Exception CreateInvalidCharException(
string data,
int invCharPos, ExceptionType exceptionType)
1883 return CreateException(
"Xml_InvalidCharacter", XmlException.BuildCharExceptionArgs(data, invCharPos), exceptionType, 0, invCharPos + 1);
1886 internal static Exception CreateInvalidCharException(
char invChar,
char nextChar)
1888 return CreateInvalidCharException(invChar, nextChar, ExceptionType.ArgumentException);
1891 internal static Exception CreateInvalidCharException(
char invChar,
char nextChar, ExceptionType exceptionType)
1893 return CreateException(
"Xml_InvalidCharacter", XmlException.BuildCharExceptionArgs(invChar, nextChar), exceptionType);
1896 internal static Exception CreateInvalidNameCharException(
string name,
int index, ExceptionType exceptionType)
1898 return CreateException((index == 0) ?
"Xml_BadStartNameChar" :
"Xml_BadNameChar", XmlException.BuildCharExceptionArgs(name, index), exceptionType, 0, index + 1);
1901 internal static ArgumentException CreateInvalidNameArgumentException(
string name,
string argumentName)
1905 return new ArgumentException(Res.GetString(
"Xml_EmptyName"), argumentName);
1907 return new ArgumentNullException(argumentName);
UriKind
Defines the kinds of T:System.Uris for the M:System.Uri.IsWellFormedUriString(System....
static string ToString(DateTimeOffset value)
Converts the supplied T:System.DateTimeOffset to a T:System.String.
override string ToString()
Creates and returns a string representation of the current exception.
static string ToString(double value)
Converts the T:System.Double to a T:System.String.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
static DateTime ToDateTime(string s)
Converts the T:System.String to a T:System.DateTime equivalent.
static unsafe bool IsXmlChar(char ch)
Checks if the passed-in character is a valid XML character.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static float ToSingle(string s)
Converts the T:System.String to a T:System.Single equivalent.
static DateTime ParseExact(string s, string format, IFormatProvider provider)
Converts the specified string representation of a date and time to its T:System.DateTime equivalent u...
static string ToString(ushort value)
Converts the T:System.UInt16 to a T:System.String.
bool MoveNext()
Advances the enumerator to the next element of the collection.
Represents a point in time, typically expressed as a date and time of day, relative to Coordinated Un...
static DateTimeOffset ToDateTimeOffset(string s, string format)
Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.
static char ToChar(string s)
Converts the T:System.String to a T:System.Char equivalent.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static DateTimeOffset ToDateTimeOffset(string s, string[] formats)
Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.
static string VerifyWhitespace(string content)
Returns the passed-in string instance if all the characters in the string argument are valid whitespa...
static bool IsPublicIdChar(char ch)
Returns the passed-in character instance if the character in the argument is a valid public id charac...
static string VerifyPublicId(string publicId)
Returns the passed in string instance if all the characters in the string argument are valid public i...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
static string VerifyXmlChars(string content)
Returns the passed-in string if all the characters and surrogate pair characters in the string argume...
static long ToInt64(string s)
Converts the T:System.String to a T:System.Int64 equivalent.
static string EncodeName(string name)
Converts the name to a valid XML name.
static string ToString(bool value)
Converts the T:System.Boolean to a T:System.String.
static string EncodeLocalName(string name)
Converts the name to a valid XML local name.
static string DecodeName(string name)
Decodes a name. This method does the reverse of the M:System.Xml.XmlConvert.EncodeName(System....
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
static string ToString(DateTimeOffset value, string format)
Converts the supplied T:System.DateTimeOffset to a T:System.String in the specified format.
static string ToString(DateTime value, string format)
Converts the T:System.DateTime to a T:System.String.
A type representing a date and time value.
static DateTime ToDateTime(string s, string format)
Converts the T:System.String to a T:System.DateTime equivalent.
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
static string EncodeNmToken(string name)
Verifies the name is valid according to the XML specification.
static string ToString(float value)
Converts the T:System.Single to a T:System.String.
static Guid ToGuid(string s)
Converts the T:System.String to a T:System.Guid equivalent.
static byte ToByte(string s)
Converts the T:System.String to a T:System.Byte equivalent.
static string VerifyName(string name)
Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation.
static string ToString(decimal value)
Converts the T:System.Decimal to a T:System.String.
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
static string ToString(sbyte value)
Converts the T:System.SByte to a T:System.String.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
static uint ToUInt32(string s)
Converts the T:System.String to a T:System.UInt32 equivalent.
A cast or conversion operation, such as (SampleType)obj in C::or CType(obj, SampleType) in Visual Bas...
static string ToString(ulong value)
Converts the T:System.UInt64 to a T:System.String.
StringSplitOptions
Specifies whether applicable Overload:System.String.Split method overloads include or omit empty subs...
IEnumerator GetEnumerator()
Provides an enumerator that iterates through the collection.
int Index
The position in the original string where the first character of the captured substring is found.
static string ToString(byte value)
Converts the T:System.Byte to a T:System.String.
static string ToString(DateTime value)
Converts the T:System.DateTime to a T:System.String.
static string ToString(int value)
Converts the T:System.Int32 to a T:System.String.
static string ToString(Guid value)
Converts the T:System.Guid to a T:System.String.
object Current
Gets the element in the collection at the current position of the enumerator.
static DateTimeOffset ParseExact(string input, string format, IFormatProvider formatProvider)
Converts the specified string representation of a date and time to its T:System.DateTimeOffset equiva...
static unsafe bool IsNCNameChar(char ch)
Checks whether the passed-in character is a valid non-colon character type.
static string VerifyTOKEN(string token)
Verifies that the string is a valid token according to the W3C XML Schema Part2: Datatypes recommenda...
static unsafe bool IsStartNCNameChar(char ch)
Checks if the passed-in character is a valid Start Name Character type.
static DateTime ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption)
Converts the T:System.String to a T:System.DateTime using the T:System.Xml.XmlDateTimeSerializationMo...
static string VerifyNMTOKEN(string name)
Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommen...
static TimeSpan ToTimeSpan(string s)
Converts the T:System.String to a T:System.TimeSpan equivalent.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
Returns detailed information about the last exception.
Represents the results from a single regular expression match.
The exception that is thrown when one of the arguments provided to a method is not valid.
static string ToString(short value)
Converts the T:System.Int16 to a T:System.String.
static string VerifyNCName(string name)
Verifies that the name is a valid NCName according to the W3C Extended Markup Language recommendation...
static ulong ToUInt64(string s)
Converts the T:System.String to a T:System.UInt64 equivalent.
static DateTime ToDateTime(string s, string[] formats)
Converts the T:System.String to a T:System.DateTime equivalent.
static ushort ToUInt16(string s)
Converts the T:System.String to a T:System.UInt16 equivalent.
static readonly TimeSpan MinValue
Represents the minimum T:System.TimeSpan value. This field is read-only.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
static unsafe bool IsWhitespaceChar(char ch)
Checks if the passed-in character is a valid XML whitespace character.
DateTimeKind
Specifies whether a T:System.DateTime object represents a local time, a Coordinated Universal Time (U...
static bool ToBoolean(string s)
Converts the T:System.String to a T:System.Boolean equivalent.
Represents a time interval.To browse the .NET Framework source code for this type,...
static string ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption)
Converts the T:System.DateTime to a T:System.String using the T:System.Xml.XmlDateTimeSerializationMo...
static short ToInt16(string s)
Converts the T:System.String to a T:System.Int16 equivalent.
static string ToString(long value)
Converts the T:System.Int64 to a T:System.String.
static string ToString(char value)
Converts the T:System.Char to a T:System.String.
static decimal ToDecimal(string s)
Converts the T:System.String to a T:System.Decimal equivalent.
static MatchCollection Matches(string input, string pattern)
Searches the specified input string for all occurrences of a specified regular expression.
static string ToString(TimeSpan value)
Converts the T:System.TimeSpan to a T:System.String.
static readonly Guid Empty
A read-only instance of the T:System.Guid structure whose value is all zeros.
Provides information about a specific culture (called a locale for unmanaged code development)....
Returns detailed information about the schema exception.
static bool IsXmlSurrogatePair(char lowChar, char highChar)
Checks if the passed-in surrogate pair of characters is a valid XML character.
static DateTimeOffset ToDateTimeOffset(string s)
Converts the supplied T:System.String to a T:System.DateTimeOffset equivalent.
static sbyte ToSByte(string s)
Converts the T:System.String to a T:System.SByte equivalent.
static string ToString(uint value)
Converts the T:System.UInt32 to a T:System.String.
static int ToInt32(string s)
Converts the T:System.String to a T:System.Int32 equivalent.
DateTimeStyles
Defines the formatting options that customize string parsing for some date and time parsing methods.
Represents an immutable regular expression.To browse the .NET Framework source code for this type,...
Supports a simple iteration over a non-generic collection.
XmlDateTimeSerializationMode
Specifies how to treat the time value when converting between string and T:System....
long Ticks
Gets the number of ticks that represent the date and time of this instance.
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
Represents the set of successful matches found by iteratively applying a regular expression pattern t...
static double ToDouble(string s)
Converts the T:System.String to a T:System.Double equivalent.