By default the bootstrapper will automatically add all pipelines by type in the entry assembly via reflection, but you can also use it to add or define new pipelines.
It contains several methods to add additional pipelines by either type or as an instance:
AddPipeline<TPipeline>()
will add a pipeline by type.AddPipeline(IPipeline)
and various overloads will add a pipeline instance.
Finding Pipelines By Reflection
The bootstrapper also includes the ability to use reflection to find and add pipeline types:
AddPipelines()
will add all pipelines defined in the entry assembly.AddPipelines(Assembly)
will add all pipelines defined in the specified assembly.AddPipelines(Type)
will add all pipelines defined as nested classes in the specified parent type.AddPipelines<TParent>()
will add all pipelines defined as nested classes in the specified parent type.
Typically, the name of the added pipeline is inferred from the class name though its also possible to specify an alternate name.
Adding Directly
You can add pipelines to the IPipelineCollection
directly using the following extensions:
AddPipelines(Action<IPipelineCollection>)
AddPipelines(Action<IReadOnlyConfigurationSettings, IPipelineCollection>)
Defining Pipelines
In addition to adding pipelines defined as classes, the bootstrapper also has a robust set of extensions for directly defining pipelines:
AddPipeline(...)
overloads will directly define a pipeline.AddSerialPipeline(...)
overloads will directly define a pipeline that has dependencies on all other currently defined pipelines.AddIsolatedPipeline(...)
overloads will directly define an isolated pipeline.AddDeploymentPipeline(...)
overloads will directly define a deployment pipeline.
Each of these methods have overloads that allow you to:
- Specify a collection of modules to be executed during the process phase or other phases.
- Specify files to read during the input phase.
- Specify how to write files during the output phase.
- Specify pipeline dependencies to other pipelines.
Pipeline Builder
The bootstrapper also provides a fluent API specifically for defining pipelines using a "builder" style:
BuildPipeline(string, Action<PipelineBuilder>)
specifies a pipeline name and a delegate that uses a newPipelineBuilder
.
The PipelineBuilder
includes a number of fluent methods for defining different parts of your pipeline:
WithInputReadFiles()
overloads define files to read during the input phase.WithOutputWriteFiles()
overloads define how to write files during the output phase.AsSerial()
indicates that the pipeline should have dependencies on all other currently defined pipelines.AsIsolated()
indicates that the pipeline is an isolated pipeline.AsDeployment()
indicates that the pipeline is a deployment pipeline.WithInputModules()
adds modules to the input phase.WithProcessModules()
adds modules to the process phase.WithPostProcessModules()
adds modules to the post-process phase.WithOutputModules()
adds modules to the output phase.WithInputConfig()
uses a configuration delegate to define the output of the input phase.WithProcessConfig()
uses a configuration delegate to define the output of the process phase.WithPostProcessConfig()
uses a configuration delegate to define the output of the post-process phase.WithOutputConfig()
uses a configuration delegate to define the output of the output phase.WithDependencies()
defines the dependencies for the pipeline.WithExecutionPolicy()
indicates which execution policy the pipeline should use.ManuallyExecute()
indicates the pipeline should use the manual execution policy.AlwaysExecute()
indicates the pipeline should use the always execution policy.
To complete building the pipeline call Build()
:
using System;
using System.Threading.Tasks;
using Statiq.App;
using Statiq.Markdown;
namespace MyGenerator
{
public class Program
{
public static async Task<int> Main(string[] args) =>
await Bootstrapper
.Factory
.CreateDefault(args)
.BuildPipeline("Render Markdown", builder => builder
.WithInputReadFiles("*.md")
.WithProcessModules(new RenderMarkdown())
.WithOutputWriteFiles(".html"))
.RunAsync();
}
}