Example #1
0
        /// <summary>
        /// Update the view model from  the new Documentation directory.
        /// </summary>
        public void ReactOnPathDocumentationIndexChange()
        {
            if (this.IsDocumentationLoaded)
            {
                return;
            }

            if (!File.Exists(this.PathDocumentationIndex))
            {
                throw new FileNotFoundException(string.Format("Could not find the index file at the path : '{0}'", this.pathDocumentationIndex));
            }

            this.FirstsRowSections.Clear();
            this.markdownToHtml = new MarkdownToHtml(this.RootAppData);

            var bookFileHandler = new BookFileHandler();

            this.Book = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex);

            if (this.UpdateIndexation)
            {
                this.markdownToHtml.TransformTheWholeDocumentationIntoHtml(this.Book, this.PathDocumentationIndex);
            }

            this.DocumentationSearches = new DocumentationSearches(this.PathDocumentationIndex, this.RootAppData, this.Book, this.UpdateIndexation);

            this.BookTitle = this.Book.Title ?? "Table of Contents";

            if (this.Book.Sections.Count >= 1)
            {
                foreach (var section in this.Book.Sections)
                {
                    var sectionViewModel = new SectionRowViewModel(section, null);
                    this.FirstsRowSections.Add(sectionViewModel);
                }
            }

            this.WhenAnyValue(vm => vm.SelectedSection).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ => this.ReactOnSelectionChange());

            this.LoadBookMainPage();
            this.IsDocumentationLoaded = true;

            this.WhenAnyValue(vm => vm.SearchText)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => this.ReactOnSearchTextChange());

            this.WhenAnyValue(vm => vm.SuggestedPageSelected)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => this.ReactOnSuggestedPageSelected());
        }
        public void SetUp()
        {
            this.RootAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                            "RHEA_Group");
            this.PathDocumentationIndex = Path.Combine(TestContext.CurrentContext.TestDirectory,
                                                       @"Documentation\book.json");
            var bookFileHandler = new BookFileHandler();
            var book            = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex);

            this.documentationSearches = new DocumentationSearches(this.PathDocumentationIndex, this.RootAppData, book, true);

            this.IndexDirectory     = this.documentationSearches.IndexDirectory;
            this.RamIndexDirectory  = this.documentationSearches.RamIndexDirectory;
            this.Analyzer           = this.documentationSearches.Analyzer;
            this.IndexWriter        = this.documentationSearches.IndexWriter;
            this.SearcherManager    = this.documentationSearches.SearcherManager;
            this.QueryParser        = this.documentationSearches.QueryParser;
            this.IndexWriterSuggest = this.documentationSearches.IndexWriterSuggest;
        }