Executes the input documents one at a time against the specified child modules.
- Namespace
- Statiq
.Common - Interfaces
- Base Types
-
- object
- Module
- ParentModule
graph BT
Type-->Base0["ParentModule"]
click Base0 "/api/Statiq.Common/ParentModule"
Base0-->Base1["Module"]
click Base1 "/api/Statiq.Common/Module"
Base1-->Base2["object"]
Type-.->Interface0["IModule"]
click Interface0 "/api/Statiq.Common/IModule"
Type-.->Interface1["IEnumerable<IModule>"]
Type-.->Interface2["IEnumerable"]
Type["ForEachDocument"]
class Type type-node
Syntax
public class ForEachDocument : ParentModule, IModule, IEnumerable<IModule>, IEnumerable
Examples
Pipelines.Add("ImageProcessing",
// ReadFiles will create N new documents with a Stream
// (but nothing will be read into memory yet)
ReadFiles(@"images\*"),
// Each document will be individually sent through the
// sequence of ForEach child pipelines
ForEach(
// This will load the *current* document into memory
// and perform image manipulations on it
ImageProcessor()
//...
,
// and this will save the stream to disk, replacing it with
// a file stream, thus freeing up memory for the next file
WriteFiles()
)
);
Remarks
Normally, documents are executed in a breadth-first traversal where all documents
are executed against a module before continuing with the next module. This module
allows you to conduct a depth-first traversal instead by executing each document
one at a time against the child modules before continuing with the next document.
It can be especially helpful when trying to control memory usage for large
documents such as images because it lets you move the documents through the
pipeline one at a time. The aggregate outputs from each sequence of child modules
executed against each document will be output.
Constructors
Name | Summary |
---|---|
ForEachDocument |
Specifies the modules to execute against the input document one at a time. |
Properties
Name | Property Type | Summary |
---|---|---|
Children | ModuleList |
The children of this module.
Inherited from ParentModule
|
Methods
Name | Return Value | Summary |
---|---|---|
Add |
void |
Adds modules as a child of this module.
Inherited from ParentModule
|
AfterExecution |
void |
Called after each module execution.
Inherited from Module
|
AfterExecutionAsync |
Task |
Called after each module execution.
Inherited from Module
|
BeforeExecution |
void |
Called before each module execution.
Inherited from Module
|
BeforeExecutionAsync |
Task |
Called before each module execution.
Inherited from Module
|
ExecuteAsync |
Task |
This should not be called directly, instead call
IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
|
ExecuteContextAsync |
Task |
Executes the module once for all input documents.
Inherited from Module
|
ExecuteInputAsync |
Task |
Executes the module.
|
Finally |
void |
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
|
FinallyAsync |
Task |
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
|
GetEnumerator |
IEnumerator |
Inherited from ParentModule
|