Skip to content

Commit 1e6cb03

Browse files
authored
Merge pull request #27 from ChangemakerStudios/feature/CultureIssue25
Attempt to fix Issue #25
2 parents 16ab27a + 67ac179 commit 1e6cb03

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

lib/Domain/Requests/Facets/Dimensions.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using System.Net.Http;
56
using System.Net.Http.Headers;
@@ -164,14 +165,30 @@ public IEnumerable<HttpContent> ToHttpContent()
164165

165166
if (value == null) return null;
166167

167-
var contentItem = new StringContent(value.ToString());
168-
contentItem.Headers.ContentDisposition =
169-
new ContentDispositionHeaderValue(item.Attrib.ContentDisposition) { Name = item.Attrib.Name };
168+
var contentItem = new StringContent(GetValueAsUsString(value));
169+
170+
contentItem.Headers.ContentDisposition = new ContentDispositionHeaderValue(item.Attrib.ContentDisposition) { Name = item.Attrib.Name };
170171

171172
return contentItem;
172173
}).WhereNotNull();
173174
}
174175

176+
static string GetValueAsUsString(object value)
177+
{
178+
var cultureInfo = CultureInfo.GetCultureInfo("en-US");
179+
180+
return value switch
181+
{
182+
float f => f.ToString(cultureInfo),
183+
double d => d.ToString(cultureInfo),
184+
decimal c => c.ToString(cultureInfo),
185+
int i => i.ToString(cultureInfo),
186+
long l => l.ToString(cultureInfo),
187+
DateTime date => date.ToString(cultureInfo),
188+
_ => value?.ToString()
189+
};
190+
}
191+
175192
#endregion
176193
}
177-
}
194+
}

0 commit comments

Comments
 (0)