Example #1
0
 /// <inheritdoc />
 protected override void Execute(Context context)
 {
     Result.Set(context, new DateTime(
                    Year.Get(context),
                    Month.Get(context),
                    Day.Get(context),
                    Hour.Get(context),
                    Minute.Get(context),
                    Second.Get(context),
                    Millisecond.Get(context)
                    ));
 }
Example #2
0
        // 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 (Date.Expression != null)
            {
                targetCommand.AddParameter("Date", Date.Get(context));
            }

            if (Year.Expression != null)
            {
                targetCommand.AddParameter("Year", Year.Get(context));
            }

            if (Month.Expression != null)
            {
                targetCommand.AddParameter("Month", Month.Get(context));
            }

            if (Day.Expression != null)
            {
                targetCommand.AddParameter("Day", Day.Get(context));
            }

            if (Hour.Expression != null)
            {
                targetCommand.AddParameter("Hour", Hour.Get(context));
            }

            if (Minute.Expression != null)
            {
                targetCommand.AddParameter("Minute", Minute.Get(context));
            }

            if (Second.Expression != null)
            {
                targetCommand.AddParameter("Second", Second.Get(context));
            }

            if (Millisecond.Expression != null)
            {
                targetCommand.AddParameter("Millisecond", Millisecond.Get(context));
            }

            if (DisplayHint.Expression != null)
            {
                targetCommand.AddParameter("DisplayHint", DisplayHint.Get(context));
            }

            if (UFormat.Expression != null)
            {
                targetCommand.AddParameter("UFormat", UFormat.Get(context));
            }

            if (Format.Expression != null)
            {
                targetCommand.AddParameter("Format", Format.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }