Skip to content

Commit 3bcb93f

Browse files
authored
Merge pull request #38 from toburger/fix/invariant-culture
Use culture invariant convert function
2 parents 8478481 + b96f1c3 commit 3bcb93f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Giraffe/ModelBinding.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ let bindXml<'T> (ctx : HttpHandlerContext) =
3030

3131
let bindForm<'T> (ctx : HttpHandlerContext) =
3232
async {
33-
let! form = ctx.HttpContext.Request.ReadFormAsync() |> Async.AwaitTask
33+
let! form = ctx.HttpContext.Request.ReadFormAsync() |> Async.AwaitTask
3434
let obj = Activator.CreateInstance<'T>()
3535
let props = obj.GetType().GetProperties(BindingFlags.Instance ||| BindingFlags.Public)
3636
props
37-
|> Seq.iter (fun p ->
37+
|> Seq.iter (fun p ->
3838
let strValue = ref (StringValues())
3939
if form.TryGetValue(p.Name, strValue)
4040
then
4141
let converter = TypeDescriptor.GetConverter p.PropertyType
42-
let value = converter.ConvertFromString(strValue.Value.ToString())
42+
let value = converter.ConvertFromInvariantString(strValue.Value.ToString())
4343
p.SetValue(obj, value, null))
4444
return obj
4545
}
@@ -50,19 +50,19 @@ let bindQueryString<'T> (ctx : HttpHandlerContext) =
5050
let obj = Activator.CreateInstance<'T>()
5151
let props = obj.GetType().GetProperties(BindingFlags.Instance ||| BindingFlags.Public)
5252
props
53-
|> Seq.iter (fun p ->
53+
|> Seq.iter (fun p ->
5454
let strValue = ref (StringValues())
5555
if query.TryGetValue(p.Name, strValue)
5656
then
5757
let converter = TypeDescriptor.GetConverter p.PropertyType
58-
let value = converter.ConvertFromString(strValue.Value.ToString())
58+
let value = converter.ConvertFromInvariantString(strValue.Value.ToString())
5959
p.SetValue(obj, value, null))
6060
return obj
6161
}
6262

6363
let bindModel<'T> (ctx : HttpHandlerContext) =
6464
async {
65-
let method = ctx.HttpContext.Request.Method
65+
let method = ctx.HttpContext.Request.Method
6666
return!
6767
if method.Equals "POST" || method.Equals "PUT" then
6868
let original = ctx.HttpContext.Request.ContentType

0 commit comments

Comments
 (0)