// 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 (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (FilterScript.Expression != null) { targetCommand.AddParameter("FilterScript", FilterScript.Get(context)); } if (Property.Expression != null) { targetCommand.AddParameter("Property", Property.Get(context)); } if (Value.Expression != null) { targetCommand.AddParameter("Value", Value.Get(context)); } if (EQ.Expression != null) { targetCommand.AddParameter("EQ", EQ.Get(context)); } if (CEQ.Expression != null) { targetCommand.AddParameter("CEQ", CEQ.Get(context)); } if (NE.Expression != null) { targetCommand.AddParameter("NE", NE.Get(context)); } if (CNE.Expression != null) { targetCommand.AddParameter("CNE", CNE.Get(context)); } if (GT.Expression != null) { targetCommand.AddParameter("GT", GT.Get(context)); } if (CGT.Expression != null) { targetCommand.AddParameter("CGT", CGT.Get(context)); } if (LT.Expression != null) { targetCommand.AddParameter("LT", LT.Get(context)); } if (CLT.Expression != null) { targetCommand.AddParameter("CLT", CLT.Get(context)); } if (GE.Expression != null) { targetCommand.AddParameter("GE", GE.Get(context)); } if (CGE.Expression != null) { targetCommand.AddParameter("CGE", CGE.Get(context)); } if (LE.Expression != null) { targetCommand.AddParameter("LE", LE.Get(context)); } if (CLE.Expression != null) { targetCommand.AddParameter("CLE", CLE.Get(context)); } if (Like.Expression != null) { targetCommand.AddParameter("Like", Like.Get(context)); } if (CLike.Expression != null) { targetCommand.AddParameter("CLike", CLike.Get(context)); } if (NotLike.Expression != null) { targetCommand.AddParameter("NotLike", NotLike.Get(context)); } if (CNotLike.Expression != null) { targetCommand.AddParameter("CNotLike", CNotLike.Get(context)); } if (Match.Expression != null) { targetCommand.AddParameter("Match", Match.Get(context)); } if (CMatch.Expression != null) { targetCommand.AddParameter("CMatch", CMatch.Get(context)); } if (NotMatch.Expression != null) { targetCommand.AddParameter("NotMatch", NotMatch.Get(context)); } if (CNotMatch.Expression != null) { targetCommand.AddParameter("CNotMatch", CNotMatch.Get(context)); } if (Contains.Expression != null) { targetCommand.AddParameter("Contains", Contains.Get(context)); } if (CContains.Expression != null) { targetCommand.AddParameter("CContains", CContains.Get(context)); } if (NotContains.Expression != null) { targetCommand.AddParameter("NotContains", NotContains.Get(context)); } if (CNotContains.Expression != null) { targetCommand.AddParameter("CNotContains", CNotContains.Get(context)); } if (In.Expression != null) { targetCommand.AddParameter("In", In.Get(context)); } if (CIn.Expression != null) { targetCommand.AddParameter("CIn", CIn.Get(context)); } if (NotIn.Expression != null) { targetCommand.AddParameter("NotIn", NotIn.Get(context)); } if (CNotIn.Expression != null) { targetCommand.AddParameter("CNotIn", CNotIn.Get(context)); } if (Is.Expression != null) { targetCommand.AddParameter("Is", Is.Get(context)); } if (IsNot.Expression != null) { targetCommand.AddParameter("IsNot", IsNot.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
// 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 (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (Pattern.Expression != null) { targetCommand.AddParameter("Pattern", Pattern.Get(context)); } if (Path.Expression != null) { targetCommand.AddParameter("Path", Path.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (SimpleMatch.Expression != null) { targetCommand.AddParameter("SimpleMatch", SimpleMatch.Get(context)); } if (CaseSensitive.Expression != null) { targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context)); } if (Quiet.Expression != null) { targetCommand.AddParameter("Quiet", Quiet.Get(context)); } if (List.Expression != null) { targetCommand.AddParameter("List", List.Get(context)); } if (Include.Expression != null) { targetCommand.AddParameter("Include", Include.Get(context)); } if (Exclude.Expression != null) { targetCommand.AddParameter("Exclude", Exclude.Get(context)); } if (NotMatch.Expression != null) { targetCommand.AddParameter("NotMatch", NotMatch.Get(context)); } if (AllMatches.Expression != null) { targetCommand.AddParameter("AllMatches", AllMatches.Get(context)); } if (Encoding.Expression != null) { targetCommand.AddParameter("Encoding", Encoding.Get(context)); } if (Context.Expression != null) { targetCommand.AddParameter("Context", Context.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }