Skip to content

Commit

Permalink
Update ExchangeRatesParser.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
maurizuki committed Nov 8, 2023
1 parent 9bfa287 commit 117d348
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/ECB.Data.ExchangeRates/ExchangeRatesParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// OTHER DEALINGS IN THE SOFTWARE.

using System.Globalization;
using System.Xml;
using System.Xml.Linq;

namespace ECB.Data.ExchangeRates
Expand All @@ -30,15 +31,10 @@ public class ExchangeRatesParser : IExchangeRatesParser
{
public IEnumerable<ExchangeRate> Parse(string source)

Check warning on line 32 in src/ECB.Data.ExchangeRates/ExchangeRatesParser.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExchangeRatesParser.Parse(string)'

Check warning on line 32 in src/ECB.Data.ExchangeRates/ExchangeRatesParser.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ExchangeRatesParser.Parse(string)'
{
if (string.IsNullOrWhiteSpace(source)) return new List<ExchangeRate>();

var document = XDocument.Parse(source);

if (document.Root == null) return new List<ExchangeRate>();

var genericNamespace = document.Root.GetNamespaceOfPrefix("generic");

if (genericNamespace == null) return new List<ExchangeRate>();
var genericNamespace = document.Root!.GetNamespaceOfPrefix("generic")
?? throw new XmlException("Namespace of prefix 'generic' is missing.");

var seriesKeyValueName = XName.Get("Value", genericNamespace.NamespaceName);
var obsName = XName.Get("Obs", genericNamespace.NamespaceName);
Expand Down

0 comments on commit 117d348

Please sign in to comment.