예제 #1
0
 private static string GetChecksum(FileListItem contentFile, FileListItem metaFile)
 {
     string contentChecksum = contentFile.Checksum;
     string metaChecksum = (metaFile != null) ? metaFile.Checksum : null;
     return string.Format("{0}{1}", contentChecksum, metaChecksum);
 }
예제 #2
0
        private BlogPost GetBlogPost(
            DataSourceRefreshContext refreshInfo, FileListItem contentFile, FileListItem metaFile)
        {
            if (contentFile == null)
            {
                throw new ArgumentNullException("contentFile");
            }

            string blogKey = refreshInfo.BlogSetting.BlogKey;

            string content = this.GetFileContent(contentFile.FullPath);
            string metaContent = (metaFile != null) ? this.GetFileContent(metaFile.FullPath) : null;

            var blogPost = ((!String.IsNullOrWhiteSpace(metaContent))
                                ? JsonHelper.Deserialize<BlogPost>(metaContent)
                                : null) ?? new BlogPost(blogKey);

            blogPost.BlogKey = blogPost.BlogKey ?? refreshInfo.BlogSetting.BlogKey;
            blogPost.Content = content;
            blogPost.DataSourceUrl = contentFile.FullPath;
            blogPost.Title = blogPost.Title ?? Path.GetFileNameWithoutExtension(contentFile.FullPath);
            blogPost.UrlSlug = blogPost.UrlSlug ?? UrlSlug.Create(blogPost.Title);

            blogPost.Checksum = GetChecksum(contentFile, metaFile);

            string dataSourceId = Path.GetFileNameWithoutExtension(contentFile.FullPath);
            blogPost.SetIds(dataSourceId);

            return blogPost;
        }