示例#1
0
        internal static IObservable <Unit> Connect(this XafApplication application)
        {
            if (!(application is ILoggerHubClientApplication))
            {
                TraceEventHub.Init();
            }
            var startServer = application.StartServer().Publish().RefCount();
            var client      = Observable.Start(application.ConnectClient).Merge().Publish().RefCount();

            application.CleanUpHubResources(startServer);

            var saveServerTraceMessages = application.SaveServerTraceMessages().Retry(application).Publish().RefCount();

            return(startServer.ToUnit()
                   .Merge(client.ToUnit())
                   .Merge(saveServerTraceMessages.ToUnit())
                   .Merge(application.WhenViewOnFrame(typeof(TraceEvent))
                          .SelectMany(frame => saveServerTraceMessages.LoadTracesToListView(frame)))
                   .Retry(application));
        }