@@ -36,15 +36,16 @@ static internal async Task<PSTask> CreateAsync(
3636 TaskSettings settings )
3737 {
3838 PSTask ps = new ( runspacePool ) ;
39- HookStreams ( ps . _internalStreams , runspacePool . Streams ) ;
39+ SetStreams ( ps . _internalStreams , runspacePool . Streams ) ;
4040 ps . Runspace = await runspacePool . GetRunspaceAsync ( ) ;
41- ps . AddInput ( input ) ;
42- ps . AddScript ( settings . Script ) ;
43- ps . AddUsingStatements ( settings . UsingStatements ) ;
44- return ps ;
41+
42+ return ps
43+ . AddInput ( input )
44+ . AddScript ( settings . Script )
45+ . AddUsingStatements ( settings . UsingStatements ) ;
4546 }
4647
47- private static void HookStreams (
48+ private static void SetStreams (
4849 PSDataStreams streams ,
4950 PSOutputStreams outputStreams )
5051 {
@@ -63,7 +64,7 @@ private static Task InvokePowerShellAsync(
6364 powerShell . BeginInvoke < PSObject , PSObject > ( null , output ) ,
6465 powerShell . EndInvoke ) ;
6566
66- private void AddInput ( object ? inputObject )
67+ private PSTask AddInput ( object ? inputObject )
6768 {
6869 if ( inputObject is not null )
6970 {
@@ -72,17 +73,24 @@ private void AddInput(object? inputObject)
7273 . AddArgument ( "_" )
7374 . AddArgument ( inputObject ) ;
7475 }
76+
77+ return this ;
7578 }
7679
77- private void AddScript ( string script ) =>
80+ private PSTask AddScript ( string script )
81+ {
7882 _powershell . AddScript ( script , useLocalScope : true ) ;
83+ return this ;
84+ }
7985
80- private void AddUsingStatements ( Dictionary < string , object ? > usingParams )
86+ private PSTask AddUsingStatements ( Dictionary < string , object ? > usingParams )
8187 {
8288 if ( usingParams . Count > 0 )
8389 {
8490 _powershell . AddParameter ( "--%" , usingParams ) ;
8591 }
92+
93+ return this ;
8694 }
8795
8896 internal async Task InvokeAsync ( )
0 commit comments