Skip to content

Instantly share code, notes, and snippets.

@FuncLun
Created September 20, 2018 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FuncLun/1eb07f450ca57fac05785688f80672bb to your computer and use it in GitHub Desktop.
Save FuncLun/1eb07f450ca57fac05785688f80672bb to your computer and use it in GitHub Desktop.
//C# Pipeline example
var tasks = myObject
.Select(o => o.MyString)
.Where(s => s != null)
.Select(s => new Request() { Message = s })
.Select(r => r.Send(mediator))
.ToArray();
await Task.WhenAll(tasks); //There should be an extension `Task WhenAll(this IEnumerable<Task>)`
//C# Non-Pipeline example
await Task.WhenAll(
Enumerable.ToArray(
Enumerable.Select(
Enumerable.Select(
Enumerable.Where(
Enumerable.Select(
myObject,
o => o.MyString
),
s=> s != null
),
s => new Request() { Message = s }
),
r => mediator.Send(r)
),
)
);
//PowerShell Pipeline example
Get-Process notepad `
| Stop-Process
//PowerShell Non-Pipeline example
Stop-Process -InputObject ( `
Get-Process notepad `
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment