-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace #ifdefs in XmlLayout for netstandard with extension methods
- Loading branch information
1 parent
c9e63b6
commit 2e5a79a
Showing
7 changed files
with
103 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.IO; | ||
using System.Xml; | ||
using log4net.Util; | ||
|
||
namespace log4net.Layout.Internal; | ||
|
||
partial class XmlWriterExtensions | ||
{ | ||
/// <summary> | ||
/// Writes the specified start tag and associates it with the given namespace and prefix | ||
/// </summary> | ||
/// <param name="writer">Writer</param> | ||
/// <param name="fullName">The full name of the element</param> | ||
/// <param name="prefix">The namespace prefix of the element (ignored for net4x)</param> | ||
/// <param name="localName">The local name of the element (ignored for net4x)</param> | ||
/// <param name="ns">The namespace URI to associate with the element (ignored for net4x)</param> | ||
internal static void WriteStartElement(this XmlWriter writer, | ||
string fullName, string prefix, string localName, string ns) | ||
=> writer.WriteStartElement(fullName); | ||
|
||
/// <summary> | ||
/// Creates an XmlWriter | ||
/// </summary> | ||
/// <param name="writer">TextWriter</param> | ||
/// <returns>XmlWriter</returns> | ||
internal static XmlWriter CreateXmlWriter(TextWriter writer) | ||
=> new XmlTextWriter(new ProtectCloseTextWriter(writer)) | ||
{ | ||
Formatting = Formatting.None, | ||
Namespaces = false | ||
}; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/log4net/Layout/Internal/XmlWriterExtensions.NetStandard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.IO; | ||
using System.Xml; | ||
using log4net.Util; | ||
|
||
namespace log4net.Layout.Internal; | ||
|
||
partial class XmlWriterExtensions | ||
{ | ||
private static readonly XmlWriterSettings settings = new XmlWriterSettings | ||
{ | ||
Indent = false, | ||
OmitXmlDeclaration = true | ||
}; | ||
|
||
/// <summary> | ||
/// writes the specified start tag and associates it with the given namespace and prefix | ||
/// </summary> | ||
/// <param name="writer">Writer</param> | ||
/// <param name="fullName">The full name of the element (ignored for netstandard)</param> | ||
/// <param name="prefix">The namespace prefix of the element</param> | ||
/// <param name="localName">The local name of the element</param> | ||
/// <param name="ns">The namespace URI to associate with the element</param> | ||
internal static void WriteStartElement(this XmlWriter writer, | ||
string fullName, string prefix, string localName, string ns) | ||
=> writer.WriteStartElement(prefix, localName, ns); | ||
|
||
/// <summary> | ||
/// Creates an XmlWriter | ||
/// </summary> | ||
/// <param name="writer">TextWriter</param> | ||
/// <returns>XmlWriter</returns> | ||
internal static XmlWriter CreateXmlWriter(TextWriter writer) | ||
=> XmlWriter.Create(new ProtectCloseTextWriter(writer), settings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace log4net.Layout.Internal; | ||
|
||
/// <summary> | ||
/// Extensions for <see cref="System.Xml.XmlWriter"/> | ||
/// </summary> | ||
/// <author>Jan Friedrich</author> | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", | ||
Justification = "Compatibility between net4 and netstandard")] | ||
internal static partial class XmlWriterExtensions | ||
{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters