示例#1
0
 public static IObservable <T> Retry <T>(this IObservable <T> source,
                                         XafApplication application)
 {
     return(source.RetryWhen(_ => _.Do(e => {
         if (application.GetPlatform() == Platform.Win)
         {
             application.CallMethod("HandleException", e);
         }
     }).SelectMany(e => application.GetPlatform() == Platform.Win?e.ReturnObservable():Observable.Empty <Exception>())));
 }
示例#2
0
        public static TestObserver <T> StartTest <T>(this XafApplication application, IObservable <T> test, int delay = 200)
        {
            var testObserver = test
                               .Timeout(TimeSpan.FromSeconds(10))
                               .AsyncFinally(async() => await Task.Delay(delay).ToObservable().Do(_ => application.Exit()).ToTask())
                               .Test();

            application.CallMethod("Start");
            return(testObserver);
        }
        public static async Task <Window> TestListView(this XafApplication application, Type objectType)
        {
            if (application.GetPlatform() == Platform.Blazor)
            {
                application.CallMethod("CreateMainWindow");
            }
            var listView = application.NewListView(objectType);
            var whenProxyCollectionChanged = ((ProxyCollection)listView.CollectionSource.Collection).Count.ReturnObservable()
                                             .SelectMany(_ => listView.CollectionSource.WhenProxyCollectionChanged()).SubscribeReplay();
            var window = application.CreateViewWindow(() => listView);
            await whenProxyCollectionChanged.FirstAsync();

            return(window);
        }
示例#4
0
 public static IObservable <T> HandleErrors <T>(this IObservable <T> source, XafApplication application, CancelEventArgs args, Func <Exception, IObservable <T> > exceptionSelector = null)
 {
     exceptionSelector ??= (exception => Observable.Empty <T>());
     return(source.Catch <T, Exception>(exception => {
         args.Cancel = true;
         if (application.GetPlatform() == Platform.Win)
         {
             application.CallMethod("HandleException", exception);
         }
         else
         {
             ErrorHandling.CallMethod("SetPageError", exception);
         }
         Tracing.Tracer.LogError(exception);
         return exception.Handle(exceptionSelector);
     }));
 }
 public static Controller CreateController(this XafApplication application, Type type)
 {
     return((Controller)application.CallMethod(new[] { type }, "CreateController"));
 }
 public static View CreateView(this XafApplication application, IModelView viewModel)
 {
     return((View)application.CallMethod("CreateView", viewModel));
 }
 public static void EnsureShowViewStrategy(this XafApplication xafApplication)
 {
     xafApplication.CallMethod("EnsureShowViewStrategy");
 }
 public static void ReadLastLogonParameters(this XafApplication application)
 {
     application.CallMethod("ReadLastLogonParameters", SecuritySystem.LogonParameters);
 }
        public static void WriteLastLogonParameters(this XafApplication application, DetailView detailView = null)
        {
            var parameterTypes = new[] { typeof(DetailView), typeof(object) };

            application.CallMethod("WriteLastLogonParameters", parameterTypes, detailView, SecuritySystem.LogonParameters);
        }
 public static IEnumerable <IObjectSpaceProvider> ObjectSpaceProviders(this XafApplication application, params Type[] objectTypes)
 => objectTypes.Select(type => application.CallMethod("GetObjectSpaceProviders", type)).Distinct().Cast <IObjectSpaceProvider>();
示例#11
0
 public static CompositeView NewView(this XafApplication application, IModelView modelView, IObjectSpace objectSpace = null)
 => (CompositeView)(objectSpace == null?(CompositeView)application.CallMethod("CreateView", modelView):application.CreateView(modelView, objectSpace));