예제 #1
0
        internal static void CreateRawItems(Settings settings, PostRepository postRepository)
        {
            var workingPath = Path.GetFullPath(WorkingFolderName);

            Directory.CreateDirectory(workingPath);
            Page template;

            using (var stream = AssemblyExtensions.OpenScopedResourceStream <Program> ("Template.xaml"))
            {
                template        = (Page)XamlReader.Load(stream);
                template.Width  = settings.ItemImageSize.Width;
                template.Height = settings.ItemImageSize.Height;
            }
            var imageFormat    = settings.PostImageEncoding;
            var imageExtension = imageFormat.ToString().ToLower();

            var posts = postRepository.RetrievePosts();

            foreach (var post in posts)
            {
                var relativeBinnedXmlPath = post.ComputeBinnedPath(".xml", settings.FileNameIdFormat);
                var absoluteBinnedXmlPath = Path.Combine(workingPath, relativeBinnedXmlPath);
                Directory.CreateDirectory(Path.GetDirectoryName(absoluteBinnedXmlPath));
                var element = PivotizePost(post);
                using (var outputStream =
                           new FileStream(absoluteBinnedXmlPath, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    using (var writer = new ItemWriter(outputStream, ItemWriterSettings))
                    {
                        element.Save(writer);
                    }
                }

                var relativeBinnedImagePath = post.ComputeBinnedPath(imageExtension, settings.FileNameIdFormat);
                var absoluteBinnedImagePath = Path.Combine(workingPath, relativeBinnedImagePath);
                Directory.CreateDirectory(Path.GetDirectoryName(absoluteBinnedImagePath));
                using (var outputStream
                           = new FileStream(absoluteBinnedImagePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    ImagePost(post, template, imageFormat, outputStream);
                }
            }
        }
예제 #2
0
        internal void CreateRawItems (PostRepository postRepository)
        {
            var workingPath = _settings.AbsoluteWorkingFolder;
            Directory.CreateDirectory (workingPath);
            Page template;
            using (var stream = AssemblyExtensions.OpenScopedResourceStream<Program> ("Template.xaml"))
            {
                template = (Page) XamlReader.Load (stream);
                template.Width = _settings.ItemImageSize.Width;
                template.Height = _settings.ItemImageSize.Height;
            }
            var imageFormat = _settings.PostImageEncoding;
            var imageExtension = imageFormat.GetName ();

            var posts = postRepository.RetrievePosts ();
            foreach (var post in posts)
            {
                var relativeBinnedXmlPath = post.ComputeBinnedPath (".xml", _settings.FileNameIdFormat);
                var absoluteBinnedXmlPath = Path.Combine (workingPath, relativeBinnedXmlPath);
                Directory.CreateDirectory (Path.GetDirectoryName (absoluteBinnedXmlPath));
                var element = PivotizePost (post);
                using (var outputStream = absoluteBinnedXmlPath.CreateWriteStream ())
                {
                    using (var writer = new ItemWriter (outputStream, _settings.XmlWriterSettings))
                    {
                        element.Save (writer);
                    }
                }

                var relativeBinnedImagePath = post.ComputeBinnedPath (imageExtension, _settings.FileNameIdFormat);
                var absoluteBinnedImagePath = Path.Combine (workingPath, relativeBinnedImagePath);
                Directory.CreateDirectory (Path.GetDirectoryName (absoluteBinnedImagePath));
                using (var outputStream = absoluteBinnedImagePath.CreateWriteStream ())
                {
                    ImagePost (post, template, imageFormat, outputStream);
                }
            }
        }