From 38181f16c9792ebf890dd95d59979b54010075f9 Mon Sep 17 00:00:00 2001 From: Edmundas Kevisas <4612388+edmundas-kevisas@users.noreply.github.com> Date: Mon, 27 Nov 2023 11:16:38 +0200 Subject: [PATCH] Accounting for situations '-' symbol is returned for null numeric values. Example response: ... "line_items": [ { ... "taxes": [ { "id": 1, "total": "-", "subtotal": "-" } ], ... } ], ... --- Base/BaseObject.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Base/BaseObject.cs b/Base/BaseObject.cs index 09beac1..6eb1a26 100644 --- a/Base/BaseObject.cs +++ b/Base/BaseObject.cs @@ -59,21 +59,21 @@ void OnDeserialized(StreamingContext ctx) { object value = objValue.GetValue(this); - if (!(value == null || value.ToString() == string.Empty)) + if (!(value == null || value.ToString() == string.Empty || value.ToString() == "-")) pi.SetValue(this, decimal.Parse(value.ToString(), Culture)); } else if (pi.PropertyType == typeof(int?)) { object value = objValue.GetValue(this); - if (!(value == null || value.ToString() == string.Empty)) + if (!(value == null || value.ToString() == string.Empty || value.ToString() == "-")) pi.SetValue(this, int.Parse(value.ToString(), Culture)); } else if (pi.PropertyType == typeof(DateTime?)) { object value = objValue.GetValue(this); - if (!(value == null || value.ToString() == string.Empty)) + if (!(value == null || value.ToString() == string.Empty || value.ToString() == "-")) pi.SetValue(this, DateTime.Parse(value.ToString())); } }