protected sealed override object getValue() { var processStartInfo = new ProcessStartInfo(); if (FileName != null) { processStartInfo.FileName = FileName.GetValue(); } if (Arguments != null) { processStartInfo.Arguments = Arguments.GetValue(); } if (CreateNoWindow != null) { processStartInfo.CreateNoWindow = CreateNoWindow.GetValue(); } if (UseShellExecute != null) { processStartInfo.UseShellExecute = UseShellExecute.GetValue(); } if (RedirectStandardInput != null) { processStartInfo.RedirectStandardInput = RedirectStandardInput.GetValue(); } if (RedirectStandardOutput != null) { processStartInfo.RedirectStandardOutput = RedirectStandardOutput.GetValue(); } if (RedirectStandardError != null) { processStartInfo.RedirectStandardError = RedirectStandardError.GetValue(); } if (Domain != null) { processStartInfo.Domain = Domain.GetValue(); } if (UserName != null) { processStartInfo.UserName = UserName.GetValue(); } if (Password != null) { processStartInfo.Password = Password.GetValue(); } if (ErrorDialog != null) { processStartInfo.ErrorDialog = ErrorDialog.GetValue(); } if (ErrorDialogParentHandle != null) { processStartInfo.ErrorDialogParentHandle = ErrorDialogParentHandle.GetValue(); } if (LoadUserProfile != null) { processStartInfo.LoadUserProfile = LoadUserProfile.GetValue(); } if (PasswordInClearText != null) { processStartInfo.PasswordInClearText = PasswordInClearText.GetValue(); } if (StandardOutputEncoding != null) { processStartInfo.StandardOutputEncoding = StandardOutputEncoding.GetValue(); } if (StandardErrorEncoding != null) { processStartInfo.StandardErrorEncoding = StandardErrorEncoding.GetValue(); } if (Verb != null) { processStartInfo.Verb = Verb.GetValue(); } if (WindowStyle != null) { processStartInfo.WindowStyle = WindowStyle.GetValue(); } if (WorkingDirectory != null) { processStartInfo.WorkingDirectory = WorkingDirectory.GetValue(); } return(processStartInfo); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (FilePath.Expression != null) { targetCommand.AddParameter("FilePath", FilePath.Get(context)); } if (ArgumentList.Expression != null) { targetCommand.AddParameter("ArgumentList", ArgumentList.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (WorkingDirectory.Expression != null) { targetCommand.AddParameter("WorkingDirectory", WorkingDirectory.Get(context)); } if (LoadUserProfile.Expression != null) { targetCommand.AddParameter("LoadUserProfile", LoadUserProfile.Get(context)); } if (NoNewWindow.Expression != null) { targetCommand.AddParameter("NoNewWindow", NoNewWindow.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (RedirectStandardError.Expression != null) { targetCommand.AddParameter("RedirectStandardError", RedirectStandardError.Get(context)); } if (RedirectStandardInput.Expression != null) { targetCommand.AddParameter("RedirectStandardInput", RedirectStandardInput.Get(context)); } if (RedirectStandardOutput.Expression != null) { targetCommand.AddParameter("RedirectStandardOutput", RedirectStandardOutput.Get(context)); } if (Verb.Expression != null) { targetCommand.AddParameter("Verb", Verb.Get(context)); } if (WindowStyle.Expression != null) { targetCommand.AddParameter("WindowStyle", WindowStyle.Get(context)); } if (Wait.Expression != null) { targetCommand.AddParameter("Wait", Wait.Get(context)); } if (UseNewEnvironment.Expression != null) { targetCommand.AddParameter("UseNewEnvironment", UseNewEnvironment.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }