我正在使用并且非常享受knockout.js和Script#
的邪恶组合在探索Dependent Observables的力量时,我发现需要实现documentation
中提到的Writable变体如何在Script Sharp导入类中捕获此ko函数?
答案 0 :(得分:1)
我最终制作了一个新的“导入库”项目 并定义了缺失的部分。
namespace KnockoutApi
{
[Imported]
[IgnoreNamespace]
[ScriptName("ko")]
public static class Ko
{
/// <summary>
/// Creates an observable with a value computed from one or more other values.
/// </summary>
/// <typeparam name="T">The type of the observable value.</typeparam>
/// <param name="options">Options for the dependent observable.</param>
public static DependentObservable<T> DependentObservable<T>(DependentObservableWritableOptions<T> options)
{
return null;
}
}
}
[IgnoreNamespace]
[Imported]
[ScriptName("Object")]
public class DependentObservableWritableOptions<T>
{
public DependentObservableWritableOptions()
{ }
// Summary:
// Gets or sets whether the evaluation should be deferred, i.e. not performed
// when the observable is first created.
[IntrinsicProperty]
public bool DeferEvaluation { get; set; }
//
// Summary:
// Gets or sets the function to compute the value.
[ScriptName("read")]
[IntrinsicProperty]
public Func<T> GetValueFunction { get; set; }
//
// Summary:
// Gets or sets the function to compute the value.
[ScriptName("write")]
[IntrinsicProperty]
public Action<T> SetValueFunction { get; set; }
//
// Summary:
// Gets the model instance which acts as 'this' in the get value function.
[IntrinsicProperty]
[ScriptName("owner")]
public object Model { get; set; }
}