private static FileSystemDocumentStore InitializeDocumentStore(string folder) { var fs = new FileSystemImpl(); var storeFolder = fs.Directory(folder); var isNewStore = !storeFolder.Exists; if (!storeFolder.Exists) { storeFolder.Create(); } var store = new FileSystemDocumentStore(storeFolder); store.Initialize(); if (isNewStore) { var doc = store.Create("/Welcome"); doc.Body.Blocks.Add(new Paragraph(new Run("Welcome!"))); store.SaveChanges(); } return(store); }
public NoteBookViewModel() { AutoCorrection = new AutoCorrectionTable(); AutoCorrection.Corrections.Add(new SampleCorrection()); var fs = new Plainion.IO.RealFS.FileSystemImpl(); var root = fs.Directory(RootPath); if (root.Exists) { root.Delete(true); } root.Create(); DocumentStore = new FileSystemDocumentStore(root); DocumentStore.Initialize(); DocumentStore.Create("/User documentation/Installation").Body.AddText("Installation"); DocumentStore.Create("/User documentation/Getting started").Body.AddText("Getting started"); DocumentStore.Create("/User documentation/FAQ").Body.AddText("Frequenty Asked Questions"); DocumentStore.Create("/Developer documentation/Getting started").Body.AddText("Getting started as a developer"); DocumentStore.Create("/Developer documentation/HowTos/MVC with F#").Body.AddText("MVC with F#"); DocumentStore.Create("/Developer documentation/HowTos/WebApi with F#").Body.AddText("WebApi with F#"); SaveCommand = new DelegateCommand(() => { DocumentStore.SaveChanges(); var store = new FileSystemDocumentStore(fs.Directory(RootPath)); store.Initialize(); DocumentStore = store; }); }
public ProjectService() { Location = Path.GetFullPath(GetProject()); if (!File.Exists(Location)) { File.WriteAllText(Location, "placeholder"); } Name = Path.GetFileNameWithoutExtension(Location); DocumentStoreFolder = Path.Combine(Path.GetDirectoryName(Location), "." + Name); myDocumentStore = InitializeDocumentStore(DocumentStoreFolder); myAutoSaveTimer = new DispatcherTimer(TimeSpan.FromSeconds(60), DispatcherPriority.Background, new EventHandler(DoAutoSave), Application.Current.Dispatcher); }