@@ -226,7 +226,7 @@ public virtual TSvgElement GetElementById<TSvgElement>(string id) where TSvgElem
226226 /// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
227227 public static SvgDocument Open ( string path )
228228 {
229- return Open < SvgDocument > ( path , null , null ) ;
229+ return Open < SvgDocument > ( path , new SvgOptions ( ) ) ;
230230 }
231231
232232 /// <summary>
@@ -237,7 +237,7 @@ public static SvgDocument Open(string path)
237237 /// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
238238 public static T Open < T > ( string path ) where T : SvgDocument , new ( )
239239 {
240- return Open < T > ( path , null , null ) ;
240+ return Open < T > ( path , new SvgOptions ( ) ) ;
241241 }
242242
243243 /// <summary>
@@ -247,7 +247,20 @@ public static SvgDocument Open(string path)
247247 /// <param name="entities">A dictionary of custom entity definitions to be used when resolving XML entities within the document.</param>
248248 /// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
249249 /// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
250- public static T Open < T > ( string path , Dictionary < string , string > entities , string css = null ) where T : SvgDocument , new ( )
250+ [ Obsolete ( "Use Open<T>(string path, SvgOptions svgOptions)" ) ]
251+ public static T Open < T > ( string path , Dictionary < string , string > entities ) where T : SvgDocument , new ( )
252+ {
253+ return Open < T > ( path , new SvgOptions ( entities ) ) ;
254+ }
255+
256+ /// <summary>
257+ /// Opens the document at the specified path and loads the SVG contents.
258+ /// </summary>
259+ /// <param name="path">A <see cref="string"/> containing the path of the file to open.</param>
260+ /// <param name="svgOptions">A dictionary of custom entity definitions to be used when resolving XML entities within the document.</param>
261+ /// <returns>A <see cref="SvgDocument"/> with the contents loaded.</returns>
262+ /// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
263+ public static T Open < T > ( string path , SvgOptions svgOptions ) where T : SvgDocument , new ( )
251264 {
252265 if ( string . IsNullOrEmpty ( path ) )
253266 {
@@ -261,7 +274,7 @@ public static SvgDocument Open(string path)
261274
262275 using ( var stream = File . OpenRead ( path ) )
263276 {
264- var doc = Open < T > ( stream , entities , css ) ;
277+ var doc = Open < T > ( stream , svgOptions ) ;
265278 doc . BaseUri = new Uri ( System . IO . Path . GetFullPath ( path ) ) ;
266279 return doc ;
267280 }
@@ -273,7 +286,7 @@ public static SvgDocument Open(string path)
273286 /// <param name="stream">The <see cref="Stream"/> containing the SVG document to open.</param>
274287 public static T Open < T > ( Stream stream ) where T : SvgDocument , new ( )
275288 {
276- return Open < T > ( stream , null ) ;
289+ return Open < T > ( stream , new SvgOptions ( ) ) ;
277290 }
278291
279292 /// <summary>
@@ -282,21 +295,34 @@ public static SvgDocument Open(string path)
282295 /// <param name="stream">The <see cref="Stream"/> containing the SVG document to open.</param>
283296 /// <param name="entities">Custom entity definitions.</param>
284297 /// <exception cref="ArgumentNullException">The <paramref name="stream"/> parameter cannot be <c>null</c>.</exception>
285- public static T Open < T > ( Stream stream , Dictionary < string , string > entities , string css = null ) where T : SvgDocument , new ( )
298+ [ Obsolete ( "Use Open<T>(Stream stream, SvgOptions svgOptions)" ) ]
299+ public static T Open < T > ( Stream stream , Dictionary < string , string > entities )
300+ where T : SvgDocument , new ( )
301+ {
302+ return Open < T > ( stream , new SvgOptions ( entities ) ) ;
303+ }
304+
305+ /// <summary>
306+ /// Opens an SVG document from the specified <see cref="Stream"/> and adds the specified entities.
307+ /// </summary>
308+ /// <param name="stream">The <see cref="Stream"/> containing the SVG document to open.</param>
309+ /// <param name="svgOptions">Css Style that will be applied to the Svg Document</param>
310+ /// <exception cref="ArgumentNullException">The <paramref name="stream"/> parameter cannot be <c>null</c>.</exception>
311+ public static T Open < T > ( Stream stream , SvgOptions svgOptions ) where T : SvgDocument , new ( )
286312 {
287313 if ( stream == null )
288314 {
289315 throw new ArgumentNullException ( "stream" ) ;
290316 }
291317
292318 // Don't close the stream via a dispose: that is the client's job.
293- var reader = new SvgTextReader ( stream , entities )
319+ var reader = new SvgTextReader ( stream , svgOptions . Entities )
294320 {
295321 XmlResolver = new SvgDtdResolver ( ) ,
296322 WhitespaceHandling = WhitespaceHandling . Significant ,
297323 DtdProcessing = DisableDtdProcessing ? DtdProcessing . Ignore : DtdProcessing . Parse ,
298324 } ;
299- return Create < T > ( reader , css ) ;
325+ return Create < T > ( reader , svgOptions . Css ) ;
300326 }
301327
302328 /// <summary>
0 commit comments