void InitEngineControl(DeviceEngineControl engineControl, AnalyticsEngine engine, AnalyticsArgs args, string ctrltoken = null) { //try to remove and clear all needed data if (engineControl.Content is IDisposable) { var disp = engineControl.Content as IDisposable; //try to remove content from disposables collection if (disposables.Contains(disp)) disposables.Remove(disp); //dispose existing control disp.Dispose(); } //Begin load channels section disposables.Add(EnginesView.Load(engine, args.capabilities, args.nvtSession, args.odmSession, ctrltoken) .ObserveOnCurrentDispatcher() .Subscribe(ctrlArgs => { if (ctrlArgs.selectedEngineControl != null) engineControl.Title = ctrlArgs.engine.name + ": " + ctrlArgs.selectedEngineControl.name; else engineControl.Title = ctrlArgs.engine.name; EnginesView enginesView = new EnginesView(container); disposables.Add(enginesView); enginesView.Init(ctrlArgs); engineControl.Content = enginesView; }, err => { ErrorView errorView = new ErrorView(err); disposables.Add(errorView); engineControl.Content = errorView; } )); }
void InitEngineControl(DeviceEngineControl engineControl, AnalyticsEngine engine, AnalyticsArgs args, string ctrltoken = null) { //try to remove and clear all needed data if (engineControl.Content is IDisposable) { var disp = engineControl.Content as IDisposable; //try to remove content from disposables collection if (disposables.Contains(disp)) { disposables.Remove(disp); } //dispose existing control disp.Dispose(); } //Begin load channels section disposables.Add(EnginesView.Load(engine, args.capabilities, args.nvtSession, args.odmSession, ctrltoken) .ObserveOnCurrentDispatcher() .Subscribe(ctrlArgs => { if (ctrlArgs.selectedEngineControl != null) { engineControl.Title = ctrlArgs.engine.name + ": " + ctrlArgs.selectedEngineControl.name; } else { engineControl.Title = ctrlArgs.engine.name; } EnginesView enginesView = new EnginesView(container); disposables.Add(enginesView); enginesView.Init(ctrlArgs); engineControl.Content = enginesView; }, err => { ErrorView errorView = new ErrorView(err); disposables.Add(errorView); engineControl.Content = errorView; } )); }