F#Yaml类型提供程序

F#Yaml类型提供程序,f#,yaml,fsharp.data.typeproviders,F#,Yaml,Fsharp.data.typeproviders,我已尝试在配置文件中使用Yaml贴图集合: Companies: - code: 11 name: A country: FR functionalCurrency: EUR - code: 12 name: B country: GB functionalCurrency: GBP 但是,当尝试使用类型提供程序读取它时,它只会找到列表的第一个结果 与: open FSharp.Configuration type Compani

我已尝试在配置文件中使用Yaml贴图集合:

Companies:
  - code: 11
    name: A
    country: FR
    functionalCurrency: EUR
  - code: 12
    name: B
    country: GB
    functionalCurrency: GBP
但是,当尝试使用类型提供程序读取它时,它只会找到列表的第一个结果

与:

  open FSharp.Configuration
  type CompaniesConfig = YamlConfig<"Config.yaml">  
  let config = CompaniesConfig()
尝试在线解析代码是有效的,因此我想知道这是库限制还是


感谢您的帮助

您需要实际加载文件,而不仅仅是直接使用模式:
config.load(yamlFile)
。这在文档中可能会更加明确。我在链接中使用了示例文件

#if INTERACTIVE
#r @"..\packages\FSharp.Configuration.0.6.1\lib\net40\FSharp.Configuration.dll"
#endif

open FSharp.Configuration
open System.IO

/// https://github.com/fsprojects/FSharp.Configuration/blob/master/tests/FSharp.Configuration.Tests/Lists.yaml

[<Literal>]
let yamlFile = __SOURCE_DIRECTORY__ + "..\Lists.yaml"

File.Exists yamlFile

type TestConfig = YamlConfig<yamlFile>
let config = TestConfig()

config.Load(yamlFile)
config.items.Count
config.items
#如果是交互式的
#r@..\packages\FSharp.Configuration.0.6.1\lib\net40\FSharp.Configuration.dll”
#恩迪夫
打开FSharp.Configuration
开放系统
/// https://github.com/fsprojects/FSharp.Configuration/blob/master/tests/FSharp.Configuration.Tests/Lists.yaml
[]
让yamlFile=\uuuuuu源文件\uuuu目录+“。\Lists.yaml”
存在yamlFile文件
类型TestConfig=YamlConfig
让config=TestConfig()
config.Load(yamlFile)
config.items.Count
config.items
我得到两项:

> 
val it : int = 2
> 
val it : System.Collections.Generic.IList<TestConfig.items_Item_Type> =
  seq
    [FSharp.Configuration.TestConfig+items_Item_Type
       {descrip = "Water Bucket (Filled)";
        part_no = "A4786";
        price = 147;
        quantity = 4;};
     FSharp.Configuration.TestConfig+items_Item_Type
       {descrip = "High Heeled "Ruby" Slippers";
        part_no = "E1628";
        price = 10027;
        quantity = 1;}]
> 
>
val it:int=2
> 
val it:System.Collections.Generic.IList=
序号
[FSharp.Configuration.TestConfig+items\u Item\u Type
{descripp=“水桶(已装满)”;
零件号为“A4786”;
价格=147;
数量=4;};
FSharp.Configuration.TestConfig+items\u Item\u类型
{descripp=“高跟”红宝石”拖鞋;
零件号为“E1628”;
价格=10027;
数量=1;}]
> 
> 
val it : int = 2
> 
val it : System.Collections.Generic.IList<TestConfig.items_Item_Type> =
  seq
    [FSharp.Configuration.TestConfig+items_Item_Type
       {descrip = "Water Bucket (Filled)";
        part_no = "A4786";
        price = 147;
        quantity = 4;};
     FSharp.Configuration.TestConfig+items_Item_Type
       {descrip = "High Heeled "Ruby" Slippers";
        part_no = "E1628";
        price = 10027;
        quantity = 1;}]
>