/// <summary> /// Load the item from disk /// </summary> /// <param name="request">The header of the item that is to be loaded</param> /// <returns>The blog item that was found</returns> public override IBlogItem Load(IBlogHeader request) { try { // Get the header record part from the base load IBlogItem headerOnly = base.Load(request); // Did it give us a valid header to now go and load the content from disk? if (headerOnly.Header.Id != "") { return(ReadBlogItem(headerOnly.Header)); } // Only should get to here if something has gone wrong throw new CouldNotLoadBlogException(); // Failed to load the content so error } catch (Exception ex) { // Something went wrong, explain why throw BlogException.Passthrough(ex, new CouldNotLoadBlogException(ex)); } }
/// <summary> /// Load the individual blog item /// </summary> /// <param name="request">The header for the blog item to be loaded</param> /// <returns>The blog item</returns> public virtual IBlogItem Load(IBlogHeader request) => items.Headers.Where(x => x.Header.Id == request.Id).FirstOrDefault();
/// <summary> /// Load the item from disk /// </summary> /// <param name="request">The header of the item we want to load from disk</param> /// <returns>The cast blog item</returns> private IBlogItem ReadBlogItem(IBlogHeader request) => Read <BlogItem>(BlogItemFilename(request.Id));