// 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 System.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 (CodeDomProvider.Expression != null) { targetCommand.AddParameter("CodeDomProvider", CodeDomProvider.Get(context)); } if (CompilerParameters.Expression != null) { targetCommand.AddParameter("CompilerParameters", CompilerParameters.Get(context)); } if (TypeDefinition.Expression != null) { targetCommand.AddParameter("TypeDefinition", TypeDefinition.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (MemberDefinition.Expression != null) { targetCommand.AddParameter("MemberDefinition", MemberDefinition.Get(context)); } if (Namespace.Expression != null) { targetCommand.AddParameter("Namespace", Namespace.Get(context)); } if (UsingNamespace.Expression != null) { targetCommand.AddParameter("UsingNamespace", UsingNamespace.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (AssemblyName.Expression != null) { targetCommand.AddParameter("AssemblyName", AssemblyName.Get(context)); } if (Language.Expression != null) { targetCommand.AddParameter("Language", Language.Get(context)); } if (ReferencedAssemblies.Expression != null) { targetCommand.AddParameter("ReferencedAssemblies", ReferencedAssemblies.Get(context)); } if (OutputAssembly.Expression != null) { targetCommand.AddParameter("OutputAssembly", OutputAssembly.Get(context)); } if (OutputType.Expression != null) { targetCommand.AddParameter("OutputType", OutputType.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (IgnoreWarnings.Expression != null) { targetCommand.AddParameter("IgnoreWarnings", IgnoreWarnings.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }