From cb01d1dbea5294e72e88007281f6516c447fb702 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Tue, 25 Jul 2023 09:54:41 -0400 Subject: [PATCH] ParseRating -> TryParseRating --- Program.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Program.cs b/Program.cs index e9b78eb..1b51b67 100644 --- a/Program.cs +++ b/Program.cs @@ -166,7 +166,7 @@ public class Photo { public async void Load() { image = await Image.LoadAsync(File); - ParseRating(image); + TryParseRating(image.Metadata.XmpProfile, out Rating); ExifProfile? exifs = image.Metadata.ExifProfile; if (exifs != null) { // FIXME: handle Orientation @@ -240,27 +240,27 @@ public class Photo { } } - private void ParseRating(Image image) { - XmpProfile? xmp = image.Metadata.XmpProfile; + private bool TryParseRating(XmpProfile? xmp, out int rating) { + rating = 0; if (xmp == null) { - return; + return false; } XDocument? doc = xmp.GetDocument(); if (doc == null) { - return; + return false; } XElement? root = doc.Root; if (root == null) { - return; + return false; } foreach (XElement elt in root.Descendants()) { if (elt.Name == "{http://ns.adobe.com/xap/1.0/}Rating") { - int rating; if (int.TryParse(elt.Value, out rating)) { - Rating = rating; + return true; } } } + return false; } public Texture Texture() {