mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Consolidating IcdXmlTextWriter partials
This commit is contained in:
@@ -162,7 +162,6 @@
|
|||||||
<Compile Include="Xml\IcdXmlException.cs" />
|
<Compile Include="Xml\IcdXmlException.cs" />
|
||||||
<Compile Include="Xml\IcdXmlReader.cs" />
|
<Compile Include="Xml\IcdXmlReader.cs" />
|
||||||
<Compile Include="Xml\IcdXmlTextWriter.cs" />
|
<Compile Include="Xml\IcdXmlTextWriter.cs" />
|
||||||
<Compile Include="Xml\IcdXmlTextWriter.SimplSharp.cs" />
|
|
||||||
<Compile Include="Xml\IcdXmlAttribute.cs" />
|
<Compile Include="Xml\IcdXmlAttribute.cs" />
|
||||||
<Compile Include="Xml\XmlReaderExtensions.cs" />
|
<Compile Include="Xml\XmlReaderExtensions.cs" />
|
||||||
<Compile Include="Xml\XmlUtils.cs" />
|
<Compile Include="Xml\XmlUtils.cs" />
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
#if SIMPLSHARP
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp.CrestronXml;
|
|
||||||
using ICD.Common.Utils.IO;
|
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Xml
|
|
||||||
{
|
|
||||||
public sealed partial class IcdXmlTextWriter
|
|
||||||
{
|
|
||||||
private readonly XmlTextWriter m_Writer;
|
|
||||||
|
|
||||||
public XmlWriter WrappedWriter { get { return m_Writer; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="stream"></param>
|
|
||||||
/// <param name="encoding"></param>
|
|
||||||
public IcdXmlTextWriter(IcdStream stream, Encoding encoding)
|
|
||||||
: this(new XmlTextWriter(stream.WrappedStream, encoding))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="textWriter"></param>
|
|
||||||
public IcdXmlTextWriter(IcdTextWriter textWriter)
|
|
||||||
: this(new XmlTextWriter(textWriter.WrappedTextWriter))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="writer"></param>
|
|
||||||
public IcdXmlTextWriter(XmlTextWriter writer)
|
|
||||||
{
|
|
||||||
m_Writer = writer;
|
|
||||||
m_Writer.Formatting = Formatting.Indented;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public void WriteStartElement(string elementName)
|
|
||||||
{
|
|
||||||
m_Writer.WriteStartElement(elementName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteElementString(string elementName, string value)
|
|
||||||
{
|
|
||||||
m_Writer.WriteElementString(elementName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteEndElement()
|
|
||||||
{
|
|
||||||
m_Writer.WriteEndElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteComment(string comment)
|
|
||||||
{
|
|
||||||
m_Writer.WriteComment(comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
m_Writer.Dispose(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteAttributeString(string attributeName, string value)
|
|
||||||
{
|
|
||||||
m_Writer.WriteAttributeString(attributeName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Flush()
|
|
||||||
{
|
|
||||||
m_Writer.Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
m_Writer.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteRaw(string xml)
|
|
||||||
{
|
|
||||||
m_Writer.WriteRaw(xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using ICD.Common.Utils.IO;
|
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Xml
|
|
||||||
{
|
|
||||||
public sealed partial class IcdXmlTextWriter
|
|
||||||
{
|
|
||||||
private readonly XmlWriter m_Writer;
|
|
||||||
|
|
||||||
public XmlWriter WrappedWriter { get { return m_Writer; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="stream"></param>
|
|
||||||
/// <param name="encoding"></param>
|
|
||||||
public IcdXmlTextWriter(IcdStream stream, Encoding encoding)
|
|
||||||
: this(XmlWriter.Create(stream.WrappedStream, GetSettings(encoding)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="textWriter"></param>
|
|
||||||
public IcdXmlTextWriter(IcdTextWriter textWriter)
|
|
||||||
: this(XmlWriter.Create(textWriter.WrappedTextWriter))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="writer"></param>
|
|
||||||
public IcdXmlTextWriter(XmlWriter writer)
|
|
||||||
{
|
|
||||||
m_Writer = writer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public void WriteStartElement(string elementName)
|
|
||||||
{
|
|
||||||
m_Writer.WriteStartElement(elementName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteElementString(string elementName, string value)
|
|
||||||
{
|
|
||||||
m_Writer.WriteElementString(elementName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteEndElement()
|
|
||||||
{
|
|
||||||
m_Writer.WriteEndElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteComment(string comment)
|
|
||||||
{
|
|
||||||
m_Writer.WriteComment(comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
m_Writer.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteAttributeString(string attributeName, string value)
|
|
||||||
{
|
|
||||||
m_Writer.WriteAttributeString(attributeName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Flush()
|
|
||||||
{
|
|
||||||
m_Writer.Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteRaw(string xml)
|
|
||||||
{
|
|
||||||
m_Writer.WriteRaw(xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Methods
|
|
||||||
|
|
||||||
private static XmlWriterSettings GetSettings(Encoding encoding)
|
|
||||||
{
|
|
||||||
return new XmlWriterSettings
|
|
||||||
{
|
|
||||||
Encoding = encoding,
|
|
||||||
Indent = true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,138 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using ICD.Common.Utils.IO;
|
||||||
|
#if SIMPLSHARP
|
||||||
|
using Crestron.SimplSharp.CrestronXml;
|
||||||
|
#else
|
||||||
|
using System.Xml;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ICD.Common.Utils.Xml
|
namespace ICD.Common.Utils.Xml
|
||||||
{
|
{
|
||||||
public sealed partial class IcdXmlTextWriter : IDisposable
|
public sealed class IcdXmlTextWriter : IDisposable
|
||||||
|
{
|
||||||
|
#if SIMPLSHARP
|
||||||
|
private readonly XmlTextWriter m_Writer;
|
||||||
|
#else
|
||||||
|
private readonly XmlWriter m_Writer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public XmlWriter WrappedWriter { get { return m_Writer; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream"></param>
|
||||||
|
/// <param name="encoding"></param>
|
||||||
|
public IcdXmlTextWriter(IcdStream stream, Encoding encoding)
|
||||||
|
#if SIMPLSHARP
|
||||||
|
: this(new XmlTextWriter(stream.WrappedStream, encoding))
|
||||||
|
#else
|
||||||
|
: this(XmlWriter.Create(stream.WrappedStream, GetSettings(encoding)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="textWriter"></param>
|
||||||
|
public IcdXmlTextWriter(IcdTextWriter textWriter)
|
||||||
|
#if SIMPLSHARP
|
||||||
|
: this(new XmlTextWriter(textWriter.WrappedTextWriter))
|
||||||
|
#else
|
||||||
|
: this(XmlWriter.Create(textWriter.WrappedTextWriter))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer"></param>
|
||||||
|
#if SIMPLSHARP
|
||||||
|
private IcdXmlTextWriter(XmlTextWriter writer)
|
||||||
|
#else
|
||||||
|
private IcdXmlTextWriter(XmlWriter writer)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
m_Writer = writer;
|
||||||
|
|
||||||
|
#if SIMPLSHARP
|
||||||
|
m_Writer.Formatting = Formatting.Indented;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public void WriteStartElement(string elementName)
|
||||||
|
{
|
||||||
|
m_Writer.WriteStartElement(elementName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteElementString(string elementName, string value)
|
||||||
|
{
|
||||||
|
m_Writer.WriteElementString(elementName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteEndElement()
|
||||||
|
{
|
||||||
|
m_Writer.WriteEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteComment(string comment)
|
||||||
|
{
|
||||||
|
m_Writer.WriteComment(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
#if SIMPLSHARP
|
||||||
|
m_Writer.Dispose(true);
|
||||||
|
#else
|
||||||
|
m_Writer.Dispose();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteAttributeString(string attributeName, string value)
|
||||||
|
{
|
||||||
|
m_Writer.WriteAttributeString(attributeName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Flush()
|
||||||
|
{
|
||||||
|
m_Writer.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
#if SIMPLSHARP
|
||||||
|
m_Writer.Close();
|
||||||
|
#else
|
||||||
|
m_Writer.Dispose();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteRaw(string xml)
|
||||||
|
{
|
||||||
|
m_Writer.WriteRaw(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
#if STANDARD
|
||||||
|
private static XmlWriterSettings GetSettings(Encoding encoding)
|
||||||
|
{
|
||||||
|
return new XmlWriterSettings
|
||||||
|
{
|
||||||
|
Encoding = encoding,
|
||||||
|
Indent = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user