namespace IoX

module Utils =
  open Newtonsoft.Json
  open System.IO

  let readConfigurationFile fn =
    JsonConvert.DeserializeObject<_>(File.ReadAllText(fn))

  let writeConfigurationFile fn conf =
    File.WriteAllText(fn, JsonConvert.SerializeObject(conf))

  type ConfigurationFile<'T>(fn: string, def: 'T) =
    let mutable conf = def

    member this.Data
      with get() = conf
      and set(v) = conf <- v

    member this.Load() =
      try conf <- readConfigurationFile(fn)
      with :? System.IO.FileNotFoundException -> ()

    member this.Save() =
      writeConfigurationFile fn conf

namespace IoX

module Utils =
  open Newtonsoft.Json
  open System.IO

  let readConfigurationFile fn =
    JsonConvert.DeserializeObject<_>(File.ReadAllText(fn))

  let writeConfigurationFile fn conf =
    File.WriteAllText(fn, JsonConvert.SerializeObject(conf))

  type ConfigurationFile<'T>(fn: string, def: 'T) =
    let mutable conf = def
    let load () =
      try conf <- readConfigurationFile(fn)
      with :? System.IO.FileNotFoundException -> ()

    do load()

    member this.Data
      with get() = conf
      and set(v) = conf <- v

    member this.Load() = load()
    member this.Save() = writeConfigurationFile fn conf

Load from file when constructing `ConfigurationFile<_>` objects
Load from file when constructing `ConfigurationFile<_>` objects

otherwise `OnLoadModules` ends up being ignored in the subtree module.
