ReactiveUI的方法有像
public static ReactiveUI.ObservableAsPropertyHelper<TRet>
ObservableToProperty<TObj, TRet>(
this TObj This,
System.IObservable<TRet> observable,
System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property,
TRet initialValue = null,
System.Reactive.Concurrency.IScheduler scheduler = null
)
Run Code Online (Sandbox Code Playgroud)
在F#中我如何构造一个像这样的对象
System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property,
Run Code Online (Sandbox Code Playgroud)
在C#中,我会做类似的事情
this.ObservableAsPropertyHelper(
observable,
me => me.MyProperty
)
Run Code Online (Sandbox Code Playgroud)
编辑
我试过了
m.ObservableToProperty(this, value, fun me -> me.Property )
Run Code Online (Sandbox Code Playgroud)
和
m.ObservableToProperty(this,
value,
new Linq.Expression.Expression(fun me -> me.Property )
Run Code Online (Sandbox Code Playgroud)
但都没有工作
我不确定新的 F# 3 查询表达式是否对您有帮助,但旧的 PowerPack(仍然很好用!)有一个扩展方法Expr.ToLinqExpression() : Expression,可以将 F# 引号表达式(即<@ fun me -> me.MyProperty @>)编译为 LINQ 表达式。
编辑: 正如 Daniel 所指出的,QuotationToLambdaExpression可以为 F# 3 完成工作。
| 归档时间: |
|
| 查看次数: |
793 次 |
| 最近记录: |