Skip to content

Commit

Permalink
Merge pull request #91 from rasmusm/master
Browse files Browse the repository at this point in the history
Added support for data in int64 to YamlConfigProvider
  • Loading branch information
vasily-kirichenko committed Mar 1, 2016
2 parents d91fb9c + b029ac4 commit 17faaa2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NUGET
NUnit.Runners (2.6.4)
Octokit (0.7.2)
Microsoft.Net.Http
SharpYaml (1.5.2)
SharpYaml (1.5.3)
SourceLink.Fake (0.4.2)
GITHUB
remote: fsharp/FAKE
Expand Down
5 changes: 5 additions & 0 deletions src/FSharp.Configuration/YamlConfigProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Helper () =
module private Parser =
type Scalar =
| Int of int
| Int64 of int64
| String of string
| TimeSpan of TimeSpan
| Bool of bool
Expand All @@ -32,13 +33,15 @@ module private Parser =
| null -> String ""
| :? System.Boolean as b -> Bool b
| :? System.Int32 as i -> Int i
| :? System.Int64 as i -> Int64 i
| :? System.Double as d -> Float d
| :? System.String as s ->
Scalar.ParseStr s
|t -> failwithf "Unknown type %s" (string (t.GetType()))
member x.UnderlyingType =
match x with
| Int x -> x.GetType()
| Int64 x -> x.GetType()
| String x -> x.GetType()
| Bool x -> x.GetType()
| TimeSpan x -> x.GetType()
Expand All @@ -47,6 +50,7 @@ module private Parser =
member x.BoxedValue =
match x with
| Int x -> box x
| Int64 x -> box x
| String x -> box x
| TimeSpan x -> box x
| Bool x -> box x
Expand Down Expand Up @@ -223,6 +227,7 @@ module private TypesFactory =
member x.ToExpr() =
match x with
| Int x -> Expr.Value x
| Int64 x -> Expr.Value x
| String x -> Expr.Value x
| Bool x -> Expr.Value x
| Float x -> Expr.Value x
Expand Down
1 change: 1 addition & 0 deletions tests/FSharp.Configuration.Tests/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DB:
ConnectionString: Data Source=server1;Initial Catalog=Database1;Integrated Security=SSPI;
NumberOfDeadlockRepeats: 5
Id: 21474836470
DefaultTimeout: 00:05:00.0000000
JustStuff:
SomeDoubleValue: 0.5
1 change: 1 addition & 0 deletions tests/FSharp.Configuration.Tests/Settings2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DB:
ConnectionString: Data Source=server1;Initial Catalog=Database1;Integrated Security=SSPI;
NumberOfDeadlockRepeats: 11
Id: 21474836470
DefaultTimeout: 0:00:06:00.0000000
JustStuff:
SomeDoubleValue: 0.5
6 changes: 6 additions & 0 deletions tests/FSharp.Configuration.Tests/YamlProvider.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ let ``Can return an int from the settings file``() =
settings.DB.NumberOfDeadlockRepeats.GetType() |> should equal typeof<int>
settings.DB.NumberOfDeadlockRepeats |> should equal 5

[<Test>]
let ``Can return an int64 from the settings file``() =
let settings = Settings()
settings.DB.Id.GetType() |> should equal typeof<int64>
settings.DB.Id |> should equal 21474836470L

[<Test>]
let ``Can return an double from the settings file``() =
let settings = Settings()
Expand Down

0 comments on commit 17faaa2

Please sign in to comment.