+
+ // it is used only from 2.1 System.Xml.Serialization.dll from
+ // MS Silverlight SDK. We don't use it so far.
+ internal static Uri ToUri (string s)
+ {
+ return new Uri (s, UriKind.RelativeOrAbsolute);
+ }
+
+#endif
+
+#if NET_4_0
+ public static bool IsNCNameChar (char ch)
+ {
+ return XmlChar.IsNCNameChar (ch);
+ }
+
+ public static bool IsPublicIdChar (char ch)
+ {
+ return XmlChar.IsPubidChar (ch);
+ }
+
+ public static bool IsStartNCNameChar (char ch)
+ {
+ return XmlChar.IsFirstNameChar (ch);
+ }
+
+ public static bool IsWhitespaceChar (char ch)
+ {
+ return XmlChar.IsWhitespace (ch);
+ }
+
+ public static bool IsXmlChar (char ch)
+ {
+ return XmlChar.IsValid (ch);
+ }
+
+ public static bool IsXmlSurrogatePair (char lowChar, char highChar)
+ {
+ return 0xD800 <= lowChar && lowChar <= 0xDBFF && 0xDC00 <= highChar && highChar <= 0xDFFF;
+ }
+
+ public static string VerifyPublicId (string publicId)
+ {
+ if (publicId == null)
+ throw new ArgumentNullException ("publicId");
+ if (XmlChar.IsPubid (publicId))
+ return publicId;
+ throw new XmlException (string.Format ("'{0}' is not a valid PUBLIC ID", publicId));
+ }
+
+ public static string VerifyWhitespace (string content)
+ {
+ if (content == null)
+ throw new ArgumentNullException ("content");
+ if (XmlChar.IsWhitespace (content))
+ return content;
+ throw new XmlException (string.Format ("'{0}' is not whitespace", content));
+ }
+
+ public static string VerifyXmlChars (string content)
+ {
+ if (content == null)
+ throw new ArgumentNullException ("content");
+ var idx = XmlChar.IndexOfInvalid (content, true);
+ if (idx < 0)
+ return content;
+ throw new XmlException (string.Format ("Invalid XML character was found in the content, at index {0}.", idx));
+ }