コード例 #1
0
        public JournalEntryFile GetEntryFromName(string name)
        {
            var entryDate = name.EndsWith(".md") ? FileNameWithExtensionPattern.Parse(name).Value : FileNamePattern.Parse(name).Value;
            var writer    = _readerWriterFactory.CreateWriter();
            var path      = writer.GetJournalEntryFilePath(entryDate);
            var reader    = _readerWriterFactory.CreateReader(path);

            return(new JournalEntryFile(reader));
        }
コード例 #2
0
        public static Journal Open(IJournalReaderWriterFactory readerWriterFactory, IMarkdownFiles markdownFiles, ISystemProcess systemProcess)
        {
            if (!MemoryCache.Default.Contains(nameof(FirstEntryDate)))
            {
                var firstEntryDate = markdownFiles
                                     .FindAll(fileNamesOnly: true)
                                     .Select(md => FileNameWithExtensionPattern.Parse(md))
                                     .Select(x => x.Value)
                                     .OrderBy(dt => dt)
                                     .First();

                MemoryCache.Default.Set(nameof(FirstEntryDate), firstEntryDate, Policy);
            }

            return(new Journal(readerWriterFactory, markdownFiles, systemProcess));
        }