mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-17 21:54:58 +00:00
Rethrowing XmlExceptions as IcdXmlExceptions
This commit is contained in:
@@ -28,7 +28,7 @@ namespace ICD.Common.Utils.Xml
|
|||||||
}
|
}
|
||||||
catch (XmlException e)
|
catch (XmlException e)
|
||||||
{
|
{
|
||||||
throw new IcdXmlException(e.Message, e, e.LineNumber, e.LinePosition);
|
throw new IcdXmlException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
#if SIMPLSHARP
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
#else
|
||||||
|
using System.Xml;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Xml
|
namespace ICD.Common.Utils.Xml
|
||||||
{
|
{
|
||||||
@@ -20,5 +25,14 @@ namespace ICD.Common.Utils.Xml
|
|||||||
m_LineNumber = lineNumber;
|
m_LineNumber = lineNumber;
|
||||||
m_LinePosition = linePosition;
|
m_LinePosition = linePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inner"></param>
|
||||||
|
public IcdXmlException(XmlException inner)
|
||||||
|
: this(inner.Message, inner, inner.LineNumber, inner.LinePosition)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,28 +49,56 @@ namespace ICD.Common.Utils.Xml
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public bool MoveToNextAttribute()
|
public bool MoveToNextAttribute()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.MoveToNextAttribute();
|
return m_Reader.MoveToNextAttribute();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveToElement()
|
public void MoveToElement()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
m_Reader.MoveToElement();
|
m_Reader.MoveToElement();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetAttribute(string name)
|
public string GetAttribute(string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.GetAttribute(name);
|
return m_Reader.GetAttribute(name);
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadString()
|
public string ReadString()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
return m_Reader.ReadString();
|
return m_Reader.ReadString();
|
||||||
#else
|
#else
|
||||||
return m_Reader.ReadElementContentAsString();
|
return m_Reader.ReadElementContentAsString();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Read()
|
public bool Read()
|
||||||
{
|
{
|
||||||
@@ -80,48 +108,97 @@ namespace ICD.Common.Utils.Xml
|
|||||||
}
|
}
|
||||||
catch (XmlException e)
|
catch (XmlException e)
|
||||||
{
|
{
|
||||||
throw new IcdXmlException(e.Message, e, e.LineNumber, e.LinePosition);
|
throw new IcdXmlException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
m_Reader.Dispose(true);
|
m_Reader.Dispose(true);
|
||||||
#else
|
#else
|
||||||
m_Reader.Dispose();
|
m_Reader.Dispose();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Skip()
|
public void Skip()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
m_Reader.Skip();
|
m_Reader.Skip();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadElementContentAsString()
|
public string ReadElementContentAsString()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.ReadElementContentAsString();
|
return m_Reader.ReadElementContentAsString();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadOuterXml()
|
public string ReadOuterXml()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.ReadOuterXml();
|
return m_Reader.ReadOuterXml();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string ReadInnerXml()
|
public string ReadInnerXml()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.ReadInnerXml();
|
return m_Reader.ReadInnerXml();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long ReadElementContentAsLong()
|
public long ReadElementContentAsLong()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.ReadElementContentAsLong();
|
return m_Reader.ReadElementContentAsLong();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public float ReadElementContentAsFloat()
|
public float ReadElementContentAsFloat()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return m_Reader.ReadElementContentAsFloat();
|
return m_Reader.ReadElementContentAsFloat();
|
||||||
}
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
throw new IcdXmlException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ namespace ICD.Common.Utils.Xml
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void Recurse(string xml, Action<XmlRecursionEventArgs> callback)
|
public static void Recurse(string xml, Action<XmlRecursionEventArgs> callback)
|
||||||
{
|
{
|
||||||
|
if (callback == null)
|
||||||
|
throw new ArgumentNullException("callback");
|
||||||
|
|
||||||
Recurse(xml, new Stack<string>(), callback);
|
Recurse(xml, new Stack<string>(), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +149,12 @@ namespace ICD.Common.Utils.Xml
|
|||||||
/// <param name="callback"></param>
|
/// <param name="callback"></param>
|
||||||
private static void Recurse(string xml, Stack<string> path, Action<XmlRecursionEventArgs> callback)
|
private static void Recurse(string xml, Stack<string> path, Action<XmlRecursionEventArgs> callback)
|
||||||
{
|
{
|
||||||
|
if (path == null)
|
||||||
|
throw new ArgumentNullException("path");
|
||||||
|
|
||||||
|
if (callback == null)
|
||||||
|
throw new ArgumentNullException("callback");
|
||||||
|
|
||||||
IcdXmlReader childReader;
|
IcdXmlReader childReader;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user