ForEach Class

Summary

Executes the input documents one at a time against the specified child modules.
Assembly
Wyam.Core.dll
Namespace
Wyam.Core.Modules.Control
Interfaces
Base Types
graph BT Type-->Base0["ContainerModule"] click Base0 "/api/Wyam.Common.Modules/ContainerModule" Base0-->Base1["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type-.->Interface1["IModuleList"] click Interface1 "/api/Wyam.Common.Modules/IModuleList" Type-.->Interface2["IList<IModule>"] Type["ForEach"] class Type type-node

Syntax

public class ForEach : ContainerModule, IModule, IModuleList, IList<IModule>

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
ForEach(IEnumerable<IModule>) Specifies the modules to execute against the input document one at a time.
ForEach(IModule[]) Specifies the modules to execute against the input document one at a time.

Properties

Name Value Summary
Count int
Inherited from ContainerModule
IsReadOnly bool
Inherited from ContainerModule
this[int] IModule
Inherited from ContainerModule
this[string] IModule
Gets the module with the specified name.
Inherited from ContainerModule

Methods

Name Value Summary
Add(IModule) void
Inherited from ContainerModule
Add(IModule[]) void
Adds modules to the list. Any null items in the sequence of modules will be discarded.
Inherited from ContainerModule
Add(string, IModule) void
Adds a module to the list with a specified name.
Inherited from ContainerModule
AsKeyValuePairs() IEnumerable<KeyValuePair<string, IModule>>
Returns the list as a sequence of key-value pairs with the keys being the module names and the values being the module instances.
Inherited from ContainerModule
Clear() void
Inherited from ContainerModule
Contains(IModule) bool
Inherited from ContainerModule
Contains(string) bool
Determines if the list contains a module with the specified name.
Inherited from ContainerModule
CopyTo(IModule[], int) void
Inherited from ContainerModule
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
GetEnumerator() IEnumerator<IModule>
Inherited from ContainerModule
IndexOf(IModule) int
Inherited from ContainerModule
IndexOf(string) int
Gets the index of the module with the specified name.
Inherited from ContainerModule
Insert(int, IModule) void
Inherited from ContainerModule
Insert(int, IModule[]) void
Inserts modules into the list. Any null items in the sequence of modules will be discarded.
Inherited from ContainerModule
Insert(int, string, IModule) void
Inserts a module into the list with a specified name.
Inherited from ContainerModule
Remove(IModule) bool
Inherited from ContainerModule
Remove(string) bool
Removes a module by name.
Inherited from ContainerModule
RemoveAt(int) void
Inherited from ContainerModule
TryGetValue(string, IModule) bool
Attempts to get a module with the specified name.
Inherited from ContainerModule
GitHub