private IEnumerable<IRenderingJob> CreateRenderingJobs(FileSystemInfo inputPath, IBatchRenderingOptions inputOutputInfo, RenderingMode? mode) { IEnumerable<IRenderingJob> output; if(inputPath != null && (inputPath is FileInfo)) { output = new [] { CreateRenderingJob((FileInfo) inputPath, mode, inputPath.GetParentDirectory()) }; } else if(inputPath != null && (inputPath is DirectoryInfo)) { var dir = (DirectoryInfo) inputPath; output = (from file in dir.GetFiles(inputOutputInfo.InputSearchPattern, SearchOption.AllDirectories) where !inputOutputInfo.IgnoredPaths.Any(x => file.IsChildOf(x)) select CreateRenderingJob(file, mode, dir)); } else { output = new IRenderingJob[0]; } return output; }
/// <summary> /// Gets the rendering context configurator for a given job. /// </summary> /// <returns>The context configurator.</returns> /// <param name="job">Job.</param> protected virtual Action<IModelValueContainer> GetContextConfigurator(IRenderingJob job) { return ctx => { if(job.InputRootDirectory != null) { var docRoot = new TemplateDirectory(job.InputRootDirectory); ctx.MetalModel.AddGlobal("documents", docRoot); } }; }
/// <summary> /// Renders a single rendering job and returns a response. /// </summary> /// <param name="job">The job to render.</param> /// <param name="options">Rendering options.</param> /// <param name="batchOptions">Batch rendering options.</param> /// <param name="contextConfigurator">Context configurator.</param> protected virtual IBatchRenderingDocumentResponse Render(IRenderingJob job, IRenderingSettings options, IBatchRenderingOptions batchOptions, Action<IModelValueContainer> contextConfigurator) { var doc = GetDocument(job); var outputInfo = GetOutputInfo(job, batchOptions); using(var outputStream = GetOutputStream(job, batchOptions)) { return Render(doc, outputStream, options, contextConfigurator, outputInfo); } }
/// <summary> /// Gets the output stream for a given rendering job. /// </summary> /// <returns>The output stream.</returns> /// <param name="job">Job.</param> /// <param name="batchOptions">Batch options.</param> protected virtual Stream GetOutputStream(IRenderingJob job, IBatchRenderingOptions batchOptions) { return job.GetOutputStream(batchOptions); }
/// <summary> /// Gets the output info for a given rendering job. /// </summary> /// <returns>The output info.</returns> /// <param name="job">Job.</param> /// <param name="batchOptions">Batch options.</param> protected virtual string GetOutputInfo(IRenderingJob job, IBatchRenderingOptions batchOptions) { return job.GetOutputInfo(batchOptions); }
/// <summary> /// Gets the document for a given rendering job. /// </summary> /// <returns>The document.</returns> /// <param name="job">Job.</param> protected virtual IZptDocument GetDocument(IRenderingJob job) { return job.GetDocument(); }