public override void Init(System.Html.Element element, Func<object> valueAccessor, Func<System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context)
        {
            //Observable<string> observable = (Observable<string>)valueAccessor();
            Observable<bool> observableBool = (Observable<bool>)valueAccessor();

            ComputedObservable interceptor = new ComputedObservable();
            interceptor.Read = delegate()
            {
                return observableBool.GetValue().ToString();
            };
            interceptor.Write = delegate(object newValue)
            {
                observableBool.SetValue((string)newValue == "true");
            };

            // Get the target binding
            string targetBinding = (string)((object)allBindingsAccessor()["targetBinding"]);

            Dictionary<string, object> bindings = new Dictionary<string, object>();
            bindings[targetBinding] = KnockoutEx.Computed(interceptor) ;

            KnockoutEx.ApplyBindingsToNode(element, bindings);

            //Script.Literal("return { controlsDescendantBindings: true };");
        }
示例#2
0
        public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context)
        {
            //Observable<string> observable = (Observable<string>)valueAccessor();
            Observable <bool> observableBool = (Observable <bool>)valueAccessor();

            ComputedObservable interceptor = new ComputedObservable();

            interceptor.Read = delegate()
            {
                return(observableBool.GetValue().ToString());
            };
            interceptor.Write = delegate(object newValue)
            {
                observableBool.SetValue((string)newValue == "true");
            };

            // Get the target binding
            string targetBinding = (string)((object)allBindingsAccessor()["targetBinding"]);

            Dictionary <string, object> bindings = new Dictionary <string, object>();

            bindings[targetBinding] = KnockoutEx.Computed(interceptor);

            KnockoutEx.ApplyBindingsToNode(element, bindings);

            //Script.Literal("return { controlsDescendantBindings: true };");
        }
示例#3
0
 public static object Computed(ComputedObservable observableDelegate)
 {
     return null;
 }
示例#4
0
 public static object Computed(ComputedObservable observableDelegate)
 {
     return(null);
 }