Skip to content

Commit

Permalink
Merge pull request #8 from vkamiansky/vi-config-file
Browse files Browse the repository at this point in the history
7 - Storing settings in the config file
  • Loading branch information
v-ilin authored Oct 2, 2017
2 parents 9c91ec6 + 24f0d7a commit 5d0e7a0
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/FsComposite/Composite.Test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DataSourceConfigs/*.json
12 changes: 8 additions & 4 deletions code/FsComposite/Composite.Test/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
<appSettings>
<add key="GithubConfigPath" value="..\..\DataSourceConfigs\github_config.json" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
</configuration>
6 changes: 6 additions & 0 deletions code/FsComposite/Composite.Test/Composite.Test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Compile Include="AssemblyInfo.fs" />
<None Include="App.config" />
<Content Include="packages.config" />
<Compile Include="DataSourceConfigurationManager.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -70,7 +71,12 @@
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.ValueTuple">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"user": "[username]",
"password": "[password]",
"repository": "[name]"
}
23 changes: 23 additions & 0 deletions code/FsComposite/Composite.Test/DataSourceConfigurationManager.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Composite.Test

open System.IO
open System.Configuration

open Newtonsoft.Json.Linq

module DataSourceConfigurationManager =

let getJsonValue (config: JObject) key =
config.SelectToken(sprintf "$.%s" key) |> string

module Github =

let config_path = ConfigurationManager.AppSettings.["GithubConfigPath"]

type Config () =
let config = JObject.Parse(File.ReadAllText(config_path))
let getJsonValueFromConfig = getJsonValue config

member this.Username = getJsonValueFromConfig "user"
member this.Password = getJsonValueFromConfig "password"
member this.Repository = getJsonValueFromConfig "repository"
2 changes: 2 additions & 0 deletions code/FsComposite/Composite.Test/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ module Program =
[<EntryPoint>]
let main argv =

let github_config = DataSourceConfigurationManager.Github.Config ()
let inputSimple = Composite ([Value C; Value D] |> LazyList.ofList)
printfn "Input seq: %A" (inputSimple |> toString)

let expanded = ana [v expandSimple] inputSimple
printfn "Expanded seq: %A" (expanded |> toString)


let collapseScn = [find_and_transform_BC ()]
let transformed = cata collapseScn (expanded |> flat)

Expand Down
1 change: 1 addition & 0 deletions code/FsComposite/Composite.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExtCore" version="0.8.46" targetFramework="net47" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net47" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net47" />
</packages>

0 comments on commit 5d0e7a0

Please sign in to comment.