Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Last active February 19, 2019 04:56
Show Gist options
  • Save JayBazuzi/8a586375d18e0ee7e4e9b8f07764db77 to your computer and use it in GitHub Desktop.
Save JayBazuzi/8a586375d18e0ee7e4e9b8f07764db77 to your computer and use it in GitHub Desktop.
//
// - 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