| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Globalization; |
| | | 5 | | using System.Xml; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Xml |
| | | 8 | | { |
| | | 9 | | internal static class XmlExceptionHelper |
| | | 10 | | { |
| | | 11 | | static void ThrowXmlException(XmlDictionaryReader reader, string res) |
| | | 12 | | { |
| | 0 | 13 | | ThrowXmlException(reader, res, null); |
| | 0 | 14 | | } |
| | | 15 | | |
| | | 16 | | static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1) |
| | | 17 | | { |
| | 0 | 18 | | ThrowXmlException(reader, res, arg1, null); |
| | 0 | 19 | | } |
| | | 20 | | |
| | | 21 | | static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2) |
| | | 22 | | { |
| | 0 | 23 | | ThrowXmlException(reader, res, arg1, arg2, null); |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2, string arg3) |
| | | 27 | | { |
| | 0 | 28 | | string s = SR.Format(res, arg1, arg2, arg3); |
| | 0 | 29 | | IXmlLineInfo lineInfo = reader as IXmlLineInfo; |
| | 0 | 30 | | if (lineInfo != null && lineInfo.HasLineInfo()) |
| | | 31 | | { |
| | 0 | 32 | | s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | //if (TD.ReaderQuotaExceededIsEnabled()) |
| | | 36 | | //{ |
| | | 37 | | // TD.ReaderQuotaExceeded(s); |
| | | 38 | | //} |
| | | 39 | | |
| | 0 | 40 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | static public void ThrowXmlException(XmlDictionaryReader reader, XmlException exception) |
| | | 44 | | { |
| | 0 | 45 | | string s = exception.Message; |
| | 0 | 46 | | IXmlLineInfo lineInfo = reader as IXmlLineInfo; |
| | 0 | 47 | | if (lineInfo != null && lineInfo.HasLineInfo()) |
| | | 48 | | { |
| | 0 | 49 | | s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); |
| | | 50 | | } |
| | 0 | 51 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | static public void ThrowMaxStringContentLengthExceeded(XmlDictionaryReader reader, int maxStringContentLength) |
| | | 55 | | { |
| | 0 | 56 | | ThrowXmlException(reader, SR.XmlMaxStringContentLengthExceeded, maxStringContentLength.ToString(NumberFormat |
| | 0 | 57 | | } |
| | | 58 | | } |
| | | 59 | | } |