type-providers

System.Linq.Enumerable.OfType<T> - is there a F# way?

送分小仙女□ 提交于 2021-02-08 05:39:15
问题 I'm looking to use the F# WSDL Type Provider. To call the web service I am using, I need to attach my client credentials to the System.ServiceModel.Description.ClientCredentials . This is the C# code I have: var serviceClient = new InvestmentServiceV1Client.InvestmentServiceV1Client(); foreach (ClientCredentials behaviour in serviceClient.Endpoint.Behaviors.OfType<ClientCredentials>()) { (behaviour).UserName.UserName = USERNAME; (behaviour).UserName.Password = PASSWORD; break; } This is the F

Can JsonProvider deserialise to a Generic.Dictionary?

安稳与你 提交于 2021-01-27 08:07:52
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

Can JsonProvider deserialise to a Generic.Dictionary?

送分小仙女□ 提交于 2021-01-27 07:58:49
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

Can JsonProvider deserialise to a Generic.Dictionary?

时光毁灭记忆、已成空白 提交于 2021-01-27 07:58:25
问题 I'm learning about type providers and it looks like a ground breaking feature. However, I can't manage to deserialise json with JsonProvider so that the target type has a Generic.Dictionary property. It can be done with Json.NET. Here is the code: type ByProv = JsonProvider<"""{"dict":{"A":1,"B":2}}"""> type ByHand(d:Dictionary<string,int>) = member val dict = d with get,set let text = """{"dict":{"C":3,"D":4}}""" let newt = JsonConvert.DeserializeObject<ByHand> text let prov = ByProv.Parse

FS2024 Static linking error when PCL project use by TypeProvider

一个人想着一个人 提交于 2020-01-14 11:45:26
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

FS2024 Static linking error when PCL project use by TypeProvider

独自空忆成欢 提交于 2020-01-14 11:44:59
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

FS2024 Static linking error when PCL project use by TypeProvider

送分小仙女□ 提交于 2020-01-14 11:44:12
问题 It's trying to make a TypeProvider for Xamarin.Forms, but has been plagued by FS2024 error. Parse own library from the XAML of Xamarin.Forms Assign x:Name to Propertis `F# type MainPage = Moonmile.XamarinFormsTypeProvider.XAML<"MainPage.xaml"> // made btn1 and text1 propertis type MainPageEx(target:MainPage) = let mutable count = 0 do // When set event to btn.Clicked, happen FS2024 error. // If this event is comment out, it success build. target.btn1.Clicked.Add( fun e -> count <- count + 1

F# TypeProvider “XMLProvider” gives System.Exception

六眼飞鱼酱① 提交于 2020-01-14 10:35:09
问题 I'm trying to process Twitter tweets using the XML type provider as represented by the code below. The code works fine when accessing tweet data values using LINQ XElement functions, however it fails with an exception saying: “XML mismatch: Expected exactly one 'title' child”, when using the type created by the XMLProvider. I know namespaces are not given, however, I don't know how they would be specified with the provider, if they're needed. // ... open FSharp.Net open FSharp.Data let ns =

Changing an immutable object F#

南笙酒味 提交于 2020-01-10 19:13:07
问题 I think the title of this is wrong but can't create a title that reflects, in the abstract, what I want to achieve. I am writing a function which calls a service and retrieves data as a JSON string. The function parses the string with a JSON type provider. Under certain conditions I want to amend properties on that JSON object and then return the string of the amended object. So if the response from the call was {"property1" : "value1","property2" : "value2", "property3": "value3" } I want to