public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory) { _objectProvider = objectProvider; InterTabClient = new InterTabClient(windowFactory); _showMenuCommand = new Command(ShowMenu, () => Selected != null && !(Selected.Content is MenuItems)); ShowInGitHubCommand = new Command(() => Process.Start("https://github.com/RolandPheasant")); var menuController = Views.ToObservableChangeSet() .Filter(vc => vc.Content is MenuItems) .Transform(vc => (MenuItems)vc.Content) .MergeMany(menuItem => menuItem.ItemCreated) .Subscribe(item => { Views.Add(item); Selected = item; }); _cleanUp = Disposable.Create(() => { menuController.Dispose(); foreach (var disposable in Views.Select(vc => vc.Content).OfType <IDisposable>()) { disposable.Dispose(); } }); }
public WindowViewModel(IObjectProvider objectProvider, IWindowFactory windowFactory) { _objectProvider = objectProvider; InterTabClient = new InterTabClient(windowFactory); _showMenuCommand = new Command(ShowMenu, () => Selected != null && !(Selected.Content is MenuItems)); ShowInGitHubCommand = new Command(() => Process.Start(new ProcessStartInfo { FileName = "cmd", Arguments = "/c start https://github.com/IgorBuchelnikov/ObservableComputations" })); Views .Filtering(vc => vc.Content is MenuItems) .Selecting(vc => (MenuItems)vc.Content) .CollectionItemProcessing((newMenuItem, _) => newMenuItem.ItemCreated.Subscribe( item => { Views.Add(item); Selected = item; })) .CollectionDisposing() .For(_consumer); }