Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// - PipeSource is split. The "take a static input" is one part. The "execute a function and broadcast the result" is another.
//
// - A FunctionPipe is like PipeMiddle, with the specific purpose of applying an A->B function to each item in the pipeline. Its last ctor parameter is the thing it listens to. (Assume it calls `predecessor.AndNext(this)`)
//
// - An overloaded FunctionPipe ctor takes a string, to identify it in the ASCII art, when the function is a lambda that doesn't have a friendly name.
// var characterFile = CharacterFile.From(fileName);
var fileNamePipe = StaticInputPipe.Of(fileName);
var characterFile = FunctionPipe.Of(CharacterFile.From, fileNamePipe);
// var configFile = ConfigFile.Matching(characterFile);
var configFile = FunctionPipe.Of(ConfigFile.Matching, characterFile);
// var partialCards = characterFile.ParseCards();
var partialCards = FunctionPipe.Of("CharacterFile.ParseCards", _ => _.ParseCards(), characterFile);
// var localCards = configFile.ParseCards();
var localCards = FunctionPipe.Of("ConfigFile.ParseCards", _ => _.ParseCards(), configFile);
// var localCards = configFile.ParseCards();
var localCards = new FunctionPipe("ConfigFile.ParseCards", _=> _.ParseCards, configFile);
// foreach (var card in partialCards)
var eachPartialCard = new ForeachPipe(partialCards);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment