Skip to content

Commit

Permalink
Fix profile parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Aug 13, 2024
1 parent 69ae69d commit 505322b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NAPS2.Lib/Scan/PerSourceProfileCaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void Serialize(PerSourceProfileCaps obj, XElement element)
{
element.Add(new XElement("ScanArea", obj.ScanArea));
}
if (obj.Resolutions != null)
if (obj.Resolutions is { Count: > 0 })
{
element.Add(new XElement("Resolutions",
string.Join(",", obj.Resolutions.Select(x => x.ToString(CultureInfo.InvariantCulture)))));
Expand All @@ -31,11 +31,11 @@ protected override void Serialize(PerSourceProfileCaps obj, XElement element)
protected override PerSourceProfileCaps Deserialize(XElement element)
{
var caps = new PerSourceProfileCaps();
if (element.Element("ScanArea") is { } scanArea)
if (element.Element("ScanArea") is { Value.Length: > 0 } scanArea)
{
caps.ScanArea = PageSize.Parse(scanArea.Value);
}
if (element.Element("Resolutions") is { } resolutions)
if (element.Element("Resolutions") is { Value.Length: > 0 } resolutions)
{
caps.Resolutions = resolutions.Value.Split(',')
.Select(x => int.Parse(x, NumberStyles.Integer, CultureInfo.InvariantCulture)).ToList();
Expand Down

0 comments on commit 505322b

Please sign in to comment.