F# quotations on Windows Phone

瘦欲@ 提交于 2019-12-12 13:33:46

问题


I'm using Daniel Mohl's F# templates for Windows phone, but it seems the bundled FSharp.Core doesn't have some of the quotations code. I'm trying to port this code from regular .NET:

open System.ComponentModel
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns

[<AbstractClass>]
type ViewModelBase() =

    let propertyChanged = new Event<_, _>()

    let toPropName expr =
        match expr with
        | PropertyGet(a, b, list) -> b.Name
        | _ -> failwith "Unsupported: " + expr.ToString()

    interface INotifyPropertyChanged with
        [<CLIEvent>]
        member x.PropertyChanged = propertyChanged.Publish

    member x.NotityPropertyChanged expr =
        propertyChanged.Trigger(x, new PropertyChangedEventArgs(toPropName expr))

But the compiler complaints about Microsoft.FSharp.Quotations.Patterns and PropertyGet. It seems it doesn't even know the Expr type. Any idea on how to solve this?


回答1:


I replaced the FSharp.Core file that comes in the template by the one that comes in the F# April 2011 CTP in the WindowsPhone7\Silverlight\4.0\bin folder, and with this version it now compiles fine




回答2:


I've compared FSharp.Core.dll from Template you've mentiond and those one which is referenced if you create a F# Silverlight library with .Net Reflector and they are different! :) Thouse one which added to template's dependencies folder doesn't have Quotations.

So my first two thoughts is either add F# SCL and create your view model there or not to use this template at all. But I actually like this template or how it looks at least... so thanks you for the mentioning it anyway :)



来源:https://stackoverflow.com/questions/10486311/f-quotations-on-windows-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!