Skip to content

Commit a59969a

Browse files
author
Lars Klein
committed
Implement review comments
Introduce new constructor Restore old constructors
1 parent 92abb11 commit a59969a

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

src/DocumentFormat.OpenXml/OpenXmlPartReader.cs

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,47 +43,64 @@ private OpenXmlPartReader(bool readMiscNodes)
4343
{
4444
}
4545

46+
/// <summary>
47+
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart class.
48+
/// </summary>
49+
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
50+
public OpenXmlPartReader(OpenXmlPart openXmlPart) : this()
51+
{
52+
if (openXmlPart is null)
53+
{
54+
throw new ArgumentNullException(nameof(openXmlPart));
55+
}
56+
57+
_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace: false, out _standalone, out _encoding);
58+
}
59+
4660
/// <summary>
4761
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart and Boolean values.
4862
/// </summary>
4963
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
5064
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
51-
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
52-
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes = false, bool ignoreWhitespace = true)
65+
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes)
5366
: this(readMiscNodes)
5467
{
5568
if (openXmlPart is null)
5669
{
5770
throw new ArgumentNullException(nameof(openXmlPart));
5871
}
5972

60-
_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace, out _standalone, out _encoding);
73+
_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace: false, out _standalone, out _encoding);
6174
}
6275

6376
/// <summary>
6477
/// Initializes a new instance of the OpenXmlPartReader class using the supplied OpenXmlPart and Boolean values.
6578
/// </summary>
6679
/// <param name="openXmlPart">The OpenXmlPart to read.</param>
6780
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
68-
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes)
69-
: this(openXmlPart, readMiscNodes, ignoreWhitespace: true)
81+
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
82+
public OpenXmlPartReader(OpenXmlPart openXmlPart, bool readMiscNodes, bool ignoreWhitespace)
83+
: this(readMiscNodes)
7084
{
85+
if (openXmlPart is null) {
86+
throw new ArgumentNullException(nameof(openXmlPart));
87+
}
88+
89+
_xmlReader = CreateReader(openXmlPart.GetStream(FileMode.Open), true, openXmlPart.MaxCharactersInPart, ignoreWhitespace, out _standalone, out _encoding);
7190
}
7291

7392
/// <summary>
7493
/// Initializes a new instance of the OpenXmlPartReader class using the supplied stream.
7594
/// </summary>
7695
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
77-
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
78-
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
79-
public OpenXmlPartReader(Stream partStream, bool readMiscNodes = false, bool ignoreWhitespace = true) : this(readMiscNodes)
96+
public OpenXmlPartReader(Stream partStream) : this()
8097
{
8198
if (partStream is null)
8299
{
83100
throw new ArgumentNullException(nameof(partStream));
84101
}
85102

86-
_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace, out _standalone, out _encoding);
103+
_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace: false, out _standalone, out _encoding);
87104
}
88105

89106
/// <summary>
@@ -92,8 +109,30 @@ public OpenXmlPartReader(Stream partStream, bool readMiscNodes = false, bool ign
92109
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
93110
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
94111
public OpenXmlPartReader(Stream partStream, bool readMiscNodes)
95-
: this(partStream, readMiscNodes, true)
112+
: this(readMiscNodes)
113+
{
114+
if (partStream is null)
115+
{
116+
throw new ArgumentNullException(nameof(partStream));
117+
}
118+
119+
_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace: false, out _standalone, out _encoding);
120+
}
121+
122+
/// <summary>
123+
/// Initializes a new instance of the OpenXmlPartReader class using the supplied stream and Boolean values.
124+
/// </summary>
125+
/// <param name="partStream">The part stream of the OpenXmlPart to read.</param>
126+
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
127+
/// <param name="ignoreWhitespace">Specify true to indicate to the reader to ignore insignificant white space. The default value is true.</param>
128+
public OpenXmlPartReader(Stream partStream, bool readMiscNodes, bool ignoreWhitespace)
129+
: this(readMiscNodes)
96130
{
131+
if (partStream is null) {
132+
throw new ArgumentNullException(nameof(partStream));
133+
}
134+
135+
_xmlReader = CreateReader(partStream, false, 0, ignoreWhitespace, out _standalone, out _encoding);
97136
}
98137

99138
/// <summary>

0 commit comments

Comments
 (0)