3

我正在为 Windows 手机使用 Daniel Mohl 的 F# 模板,但捆绑的 FSharp.Core 似乎没有一些报价代码。我正在尝试从常规 .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))

但是编译器抱怨 Microsoft.FSharp.Quotations.Patterns 和 PropertyGet。它似乎甚至不知道 Expr 类型。关于如何解决这个问题的任何想法?

4

2 回答 2

2

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

于 2012-05-11T20:43:35.980 回答
1

我比较了您提到的模板中的 FSharp.Core.dll 和使用 .Net Reflector 创建 F# Silverlight 库时引用的那些,它们是不同的!:) 添加到模板的依赖项文件夹中的 Thouse 没有引号。

所以我的前两个想法是要么添加 F# SCL 并在那里创建你的视图模型,要么根本不使用这个模板。但我实际上喜欢这个模板或者它的外观至少......所以还是谢谢你提到它:)

于 2012-05-10T11:57:59.083 回答