public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Generate a new instance of the Run PowerShell Script activity
                // and add properties based on specified values
                RunPowerShellScript wfa = new RunPowerShellScript
                {
                    ActivityDisplayName        = this.activityDisplayName.Value,
                    Advanced                   = this.advanced.Value,
                    ActivityExecutionCondition = this.activityExecutionCondition.Value,
                    PowerShellUser             = this.powerShellUser.Value,
                    PowerShellUserPassword     = this.powerShellUserPassword.Value,
                    ImpersonatePowerShellUser  = this.impersonatePowerShellUser.Value,
                    ImpersonatePowerShellUserLoadUserProfile = this.loadUserProfile.Value,
                    ImpersonatePowerShellUserLogOnType       = this.impersonatePowerShellUser.Value ? GetImpersonationLogOnType(this.impersonationLogOnType.Value) : LogOnType.None,
                    ScriptLocation    = GetScriptLocation(this.scriptLocation.Value),
                    Script            = this.script.Value,
                    FailOnMissing     = this.failOnMissing.Value,
                    InputType         = GetInputType(this.inputType.Value),
                    ReturnType        = GetReturnType(this.returnType.Value),
                    ReturnValueLookup = this.returnValueLookup.Value
                };

                // Depending on the input type selection,
                // the activity will be configured with parameters or arguments, but not both
                switch (wfa.InputType)
                {
                case PowerShellInputType.Parameters:
                {
                    DefinitionsConverter parametersConverter = new DefinitionsConverter(this.parameters.DefinitionListings);
                    wfa.ParametersTable = parametersConverter.DefinitionsTable;
                }

                break;

                case PowerShellInputType.Arguments:
                {
                    wfa.Arguments = this.FetchArguments();
                }

                break;
                }

                return(wfa);
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }
        /// <summary>
        /// This method initializes activity UI controls to their default values.
        /// </summary>
        /// <param name="activity">An instance of the current workflow activity. This provides a way to extract the values of the properties to display in the UI.</param>
        public override void LoadActivitySettings(Activity activity)
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Cast the supplied activity as a RunPowerShellScript activity
                // and load the activity controls based on dependency property settings
                RunPowerShellScript wfa = activity as RunPowerShellScript;
                if (wfa == null)
                {
                    return;
                }

                this.activityDisplayName.Value        = wfa.ActivityDisplayName;
                this.advanced.Value                   = wfa.Advanced;
                this.activityExecutionCondition.Value = wfa.ActivityExecutionCondition;
                this.powerShellUser.Value             = wfa.PowerShellUser;
                this.powerShellUserPassword.Value     = wfa.PowerShellUserPassword;
                this.impersonatePowerShellUser.Value  = wfa.ImpersonatePowerShellUser;
                this.loadUserProfile.Value            = wfa.ImpersonatePowerShellUserLoadUserProfile;
                this.impersonationLogOnType.Value     = wfa.ImpersonatePowerShellUser ? wfa.ImpersonatePowerShellUserLogOnType.ToString() : null;
                this.scriptLocation.Value             = wfa.ScriptLocation.ToString();
                this.script.Value        = wfa.Script;
                this.failOnMissing.Value = wfa.FailOnMissing;
                this.inputType.Value     = wfa.InputType.ToString();
                if (wfa.ParametersTable != null)
                {
                    this.parameters.LoadActivitySettings(wfa.ParametersTable);
                }

                this.LoadArguments(wfa.Arguments);
                this.returnType.Value        = wfa.ReturnType.ToString();
                this.returnValueLookup.Value = wfa.ReturnValueLookup;
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }