开发者

F#: a complex record type and a DataGridView

开发者 https://www.devze.com 2023-02-22 00:21 出处:网络
I have a record type like this: type Rule = {extension: string seq; subdir: string} let rules : Rule list = // ...

I have a record type like this:

type Rule = {extension: string seq; subdir: string}
let rules : Rule list = // ...

And I want to bind it's instance to DataGridView. All my UI logic is implemented with C#. What is the best way to do this? Just make a reference to FSharp.Core in my C# project and bind? Or to make some simple record like this

type SimpleRule = {extension: string; subdir: string}

and a function that converts Rule list to a SimpleRule seq, which is represented as IEnumerable in C#. The second way seems to be the best because I don't need to make开发者_StackOverflow a reference to FSharp.Core and I will work with IEnumerable, but there is too much conversion code and I am having problems with writing it. Maybe there is a better way to solve the problem?


I ended up using mutable record. Also I've created some wrapper-class for my library, which have several methods to add/delete rules and apply them, so I don't use any of F# classes such as FSharpList in C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消