Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Conflicts of Pull Request https://github.com/svg-net/SVG/pull/1094 #1107

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Source/SvgDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
/// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
public static SvgDocument Open(string path)
{
return Open<SvgDocument>(path, null);
return Open<SvgDocument>(path, null, null);
}

/// <summary>
Expand All @@ -237,7 +237,7 @@
/// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
public static T Open<T>(string path) where T : SvgDocument, new()
{
return Open<T>(path, null);
return Open<T>(path, null, null);
}

/// <summary>
Expand All @@ -247,7 +247,7 @@
/// <param name="entities">A dictionary of custom entity definitions to be used when resolving XML entities within the document.</param>
/// <returns>An <see cref="SvgDocument"/> with the contents loaded.</returns>
/// <exception cref="FileNotFoundException">The document at the specified <paramref name="path"/> cannot be found.</exception>
public static T Open<T>(string path, Dictionary<string, string> entities) where T : SvgDocument, new()
public static T Open<T>(string path, Dictionary<string, string> entities, string css = null) where T : SvgDocument, new()

Check warning on line 250 in Source/SvgDocument.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest, net6.0)

Parameter 'css' has no matching param tag in the XML comment for 'SvgDocument.Open<T>(string, Dictionary<string, string>, string)' (but other parameters do)

Check warning on line 250 in Source/SvgDocument.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest, net462)

Parameter 'css' has no matching param tag in the XML comment for 'SvgDocument.Open<T>(string, Dictionary<string, string>, string)' (but other parameters do)
{
if (string.IsNullOrEmpty(path))
{
Expand All @@ -261,7 +261,7 @@

using (var stream = File.OpenRead(path))
{
var doc = Open<T>(stream, entities);
var doc = Open<T>(stream, entities, css);
doc.BaseUri = new Uri(System.IO.Path.GetFullPath(path));
return doc;
}
Expand All @@ -282,7 +282,7 @@
/// <param name="stream">The <see cref="Stream"/> containing the SVG document to open.</param>
/// <param name="entities">Custom entity definitions.</param>
/// <exception cref="ArgumentNullException">The <paramref name="stream"/> parameter cannot be <c>null</c>.</exception>
public static T Open<T>(Stream stream, Dictionary<string, string> entities) where T : SvgDocument, new()
public static T Open<T>(Stream stream, Dictionary<string, string> entities, string css = null) where T : SvgDocument, new()

Check warning on line 285 in Source/SvgDocument.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest, net6.0)

Parameter 'css' has no matching param tag in the XML comment for 'SvgDocument.Open<T>(Stream, Dictionary<string, string>, string)' (but other parameters do)

Check warning on line 285 in Source/SvgDocument.cs

View workflow job for this annotation

GitHub Actions / test (windows-latest, net462)

Parameter 'css' has no matching param tag in the XML comment for 'SvgDocument.Open<T>(Stream, Dictionary<string, string>, string)' (but other parameters do)
{
if (stream == null)
{
Expand All @@ -296,7 +296,7 @@
WhitespaceHandling = WhitespaceHandling.Significant,
DtdProcessing = DisableDtdProcessing ? DtdProcessing.Ignore : DtdProcessing.Parse,
};
return Create<T>(reader);
return Create<T>(reader, css);
}

/// <summary>
Expand Down Expand Up @@ -343,13 +343,16 @@
}
}


private static T Create<T>(XmlReader reader) where T : SvgDocument, new()
private static T Create<T>(XmlReader reader, string css = null) where T : SvgDocument, new()
{
var styles = new List<ISvgNode>();
var elementFactory = new SvgElementFactory();

var svgDocument = Create<T>(reader, elementFactory, styles);

if (css != null) {
styles.Add(new SvgUnknownElement() { Content = css });
}

if (styles.Any())
{
Expand Down
Loading