Beispiel #1
0
 public static void RegisterJavascriptTranslations(JavascriptTranslatableMethodCollection methods)
 {
     methods.AddMethodTranslator(typeof(BindingApi), nameof(RefreshOnChange),
                                 new GenericMethodCompiler(a =>
                                                           new JsIdentifierExpression("dotvvm").Member("apiRefreshOn").Invoke(
                                                               a[1].WithAnnotation(ShouldBeObservableAnnotation.Instance),
                                                               a[2].EnsureObservableWrapped())
                                                           .WithAnnotation(a[1].Annotation <ResultIsObservableAnnotation>())
                                                           .WithAnnotation(a[1].Annotation <ViewModelInfoAnnotation>())
                                                           .WithAnnotation(a[1].Annotation <MayBeNullAnnotation>())
                                                           ));
     methods.AddMethodTranslator(typeof(BindingApi), nameof(RefreshOnEvent),
                                 new GenericMethodCompiler(a =>
                                                           new JsIdentifierExpression("dotvvm").Member("apiRefreshOn").Invoke(
                                                               a[1].WithAnnotation(ShouldBeObservableAnnotation.Instance),
                                                               new JsIdentifierExpression("dotvvm").Member("eventHub").Member("get").Invoke(a[2]))
                                                           .WithAnnotation(a[1].Annotation <ResultIsObservableAnnotation>())
                                                           .WithAnnotation(a[1].Annotation <ViewModelInfoAnnotation>())
                                                           .WithAnnotation(a[1].Annotation <MayBeNullAnnotation>())
                                                           ));
     methods.AddMethodTranslator(typeof(BindingApi), nameof(PushEvent),
                                 new GenericMethodCompiler(a =>
                                                           new JsIdentifierExpression("dotvvm").Member("eventHub").Member("notify").Invoke(a[1])
                                                           ));
 }
Beispiel #2
0
 public static void RegisterJavascriptTranslations(JavascriptTranslatableMethodCollection methods)
 {
     methods.AddMethodTranslator(typeof(LocalStorageInfo), nameof(Get),
                                 new GenericMethodCompiler((a, m) =>
                                                           new JsIdentifierExpression("dotvvm").Member("pwa").Member("get").Invoke(a[1])
                                                           .WithAnnotation(MayBeNullAnnotation.Instance)
                                                           .WithAnnotation(new ViewModelInfoAnnotation(m.ReturnType))
                                                           ));
     methods.AddMethodTranslator(typeof(LocalStorageInfo), nameof(Set),
                                 new GenericMethodCompiler(a =>
                                                           new JsIdentifierExpression("dotvvm").Member("pwa").Member("set").Invoke(
                                                               a[1], a[2].WithAnnotation(ShouldBeObservableAnnotation.Instance)
                                                               )
                                                           ));
 }