Skip to content

Commit

Permalink
Implement review comments
Browse files Browse the repository at this point in the history
Introduce new constructor
Restore old constructors
  • Loading branch information
Lars Klein committed Jan 20, 2021
1 parent 92abb11 commit d0b9eda
Showing 1 changed file with 50 additions and 10 deletions.
60 changes: 50 additions & 10 deletions src/DocumentFormat.OpenXml/OpenXmlPartReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,64 @@ private OpenXmlPartReader(bool readMiscNodes)
{
}

/// <summary>
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart class.
/// </summary>
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
public OpenXmlPartReader(OpenXmlPart openXmlPart) : this()
{
if (openXmlPart is null)
{
throw new ArgumentNullException(nameof(openXmlPart));
}

_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace: false, out _standalone, out _encoding);
}

/// <summary>
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart and Boolean values.
/// </summary>
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes = false, bool ignoreWhitespace = true)
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes)
: this(readMiscNodes)
{
if (openXmlPart is null)
{
throw new ArgumentNullException(nameof(openXmlPart));
}

_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace, out _standalone, out _encoding);
_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace: false, out _standalone, out _encoding);
}

/// <summary>
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart and Boolean values.
/// </summary>
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes)
: this(openXmlPart, readMiscNodes, ignoreWhitespace: true)
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes, bool ignoreWhitespace)
: this(readMiscNodes)
{
if (openXmlPart is null) {
throw new ArgumentNullException(nameof(openXmlPart));
}

_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace, out _standalone, out _encoding);
}

/// <summary>
/// Initializes a new instance of the OpenXmlPartReader class using the supplied stream.
/// </summary>
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
public OpenXmlPartReader(Stream partStream, bool readMiscNodes = false, bool ignoreWhitespace = true) : this(readMiscNodes)
public OpenXmlPartReader(Stream partStream) : this()
{
if (partStream is null)
{
throw new ArgumentNullException(nameof(partStream));
}

_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace, out _standalone, out _encoding);
_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace: false, out _standalone, out _encoding);
}

/// <summary>
Expand All @@ -92,10 +109,33 @@ public OpenXmlPartReader(Stream partStream, bool readMiscNodes = false, bool ign
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
public OpenXmlPartReader(Stream partStream, bool readMiscNodes)
: this(partStream, readMiscNodes, true)
: this(readMiscNodes)
{
if (partStream is null)
{
throw new ArgumentNullException(nameof(partStream));
}

_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace: false, out _standalone, out _encoding);
}

/// <summary>
/// Initializes a new instance of the OpenXmlPartReader class using the supplied stream and Boolean values.
/// </summary>
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
public OpenXmlPartReader(Stream partStream, bool readMiscNodes, bool ignoreWhitespace)
: this(readMiscNodes)
{
if (partStream is null) {
throw new ArgumentNullException(nameof(partStream));
}

_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace, out _standalone, out _encoding);
}


/// <summary>
/// Gets the encoding of the XML file.
/// </summary>
Expand Down

0 comments on commit d0b9eda

Please sign in to comment.