예제 #1
0
        /// <summary>
        /// Adds error action Powershell Parameters.
        /// </summary>
        /// <param name="errorActionType">Error action type.</param>
        /// <param name="create">true</param>
        /// <returns>PowerShell parameters.</returns>
        public RuntimeDefinedParameterDictionary AddErrorActionParameters(string errorActionType, bool create)
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(errorActionType))
            {
                if (errorActionType.Equals(Constants.HttpAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.StorageQueueAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddStorageQueueErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.ServiceBusQueueAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddServiceBusQueueErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.ServiceBusTopicAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddServiceBusTopicErrorActionParameters(create));
                }
            }

            return(runtimeDefinedParameterDictionary);
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction and/or type of http authentication.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.HttpAuthenticationType))
            {
                if (this.HttpAuthenticationType == Constants.HttpAuthenticationClientCertificate)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpClientCertificateAuthenticationTypeParameters(create: false));
                }
                else if (this.HttpAuthenticationType == Constants.HttpAuthenticationBasic)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpBasicAuthenticationTypeParameters(create: false));
                }
                else if (this.HttpAuthenticationType == Constants.HttpAuthenticationActiveDirectoryOAuth)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpActiveDirectoryOAuthAuthenticationTypeParameters(create: false));
                }
            }

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: false));
            }

            return(runtimeDefinedParameterDictionary);
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction and/or type of http authentication.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.HttpAuthenticationType))
            {
                if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationClientCertificate, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpClientCertificateAuthenticationTypeParameters());
                }
                else if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationBasic, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpBasicAuthenticationTypeParameters());
                }
                else if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationActiveDirectoryOAuth, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpActiveDirectoryOAuthAuthenticationTypeParameters());
                }
            }

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: true));
            }

            return(runtimeDefinedParameterDictionary);
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: false));
            }

            return(runtimeDefinedParameterDictionary);
        }
예제 #5
0
        /// <summary>
        /// Add service bus topic error action parameters.
        /// </summary>
        /// <param name="create">true if parameters added for create scenario and false for update scenario.</param>
        /// <returns>PowerShell parameters.</returns>
        internal RuntimeDefinedParameterDictionary AddServiceBusTopicErrorActionParameters(bool create = true)
        {
            var errorActionServiceBusTopicPathAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = create ? true : false,
                    HelpMessage = "Service bus topic path.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            this._errorActionServiceBusTopicPath = new RuntimeDefinedParameter("ErrorActionServiceBusTopicPath", typeof(string), errorActionServiceBusTopicPathAttributes);

            var runTimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusTopicPath", this._errorActionServiceBusTopicPath);
            runTimeDefinedParameterDictionary.AddRange(this.AddServiceBusErrorActionParameters(create));

            return(runTimeDefinedParameterDictionary);
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction and/or type of http authentication.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.HttpAuthenticationType))
            {
                if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationClientCertificate, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpClientCertificateAuthenticationTypeParameters());
                }
                else if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationBasic, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpBasicAuthenticationTypeParameters());
                }
                else if (this.HttpAuthenticationType.Equals(Constants.HttpAuthenticationActiveDirectoryOAuth, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpActiveDirectoryOAuthAuthenticationTypeParameters());
                }
            }

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: true));
            }

            return runtimeDefinedParameterDictionary;
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: false));
            }

            return runtimeDefinedParameterDictionary;
        }
        /// <summary>
        /// Adds http error action parameters to PowerShell.
        /// </summary>
        /// <param name="create">true if parameters added for create scenario and false for update scenario.</param>
        /// <returns>PowerShell parameters.</returns>
        internal RuntimeDefinedParameterDictionary AddHttpErrorActionParameters(bool create = true)
        {
            var errorActionMethodAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = create ? true : false,
                    HelpMessage = "The Method for Http and Https Action types (GET, PUT, POST, HEAD or DELETE).",
                },
                new ValidateSetAttribute(Constants.HttpMethodGET, Constants.HttpMethodPUT, Constants.HttpMethodPOST, Constants.HttpMethodDELETE)
                {
                    IgnoreCase = true,
                }
            };

            var errorActionUriAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = create ? true : false,
                    HelpMessage = "The Uri for error job action.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionRequestBodyAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = false,
                    HelpMessage = "The Body for PUT and POST job actions.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionHeadersAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = false,
                    HelpMessage = "The header collection."
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionHttpAuthenticationTypeAttributes = new Collection <Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory   = false,
                    HelpMessage = "The Http Authentication type."
                },
                new ValidateSetAttribute(Constants.HttpAuthenticationNone, Constants.HttpAuthenticationClientCertificate, Constants.HttpAuthenticationActiveDirectoryOAuth, Constants.HttpAuthenticationBasic)
                {
                    IgnoreCase = true
                }
            };

            this._errorActionMethod                 = new RuntimeDefinedParameter("ErrorActionMethod", typeof(string), errorActionMethodAttributes);
            this._errorActionUri                    = new RuntimeDefinedParameter("ErrorActionUri", typeof(Uri), errorActionUriAttributes);
            this._errorActionRequestBody            = new RuntimeDefinedParameter("ErrorActionRequestBody", typeof(string), errorActionRequestBodyAttributes);
            this._errorActionHeaders                = new RuntimeDefinedParameter("ErrorActionHeaders", typeof(Hashtable), errorActionHeadersAttributes);
            this._errorActionHttpAuthenticationType = new RuntimeDefinedParameter("ErrorActionHttpAuthenticationType", typeof(string), errorActionHttpAuthenticationTypeAttributes);

            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            runtimeDefinedParameterDictionary.Add("ErrorActionMethod", this._errorActionMethod);
            runtimeDefinedParameterDictionary.Add("ErrorActionUri", this._errorActionUri);
            runtimeDefinedParameterDictionary.Add("ErrorActionRequestBody", this._errorActionRequestBody);
            runtimeDefinedParameterDictionary.Add("ErrorActionHeaders", this._errorActionHeaders);
            runtimeDefinedParameterDictionary.Add("ErrorActionHttpAuthenticationType", this._errorActionHttpAuthenticationType);

            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionClientCertificateAuthenticationTypeParameters());
            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionBasicAuthenticationTypeParameters());
            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionActiveDirectoryOAuthAuthenticationTypeParameters());

            return(runtimeDefinedParameterDictionary);
        }
        /// <summary>
        /// Adds http error action parameters to PowerShell.
        /// </summary>
        /// <param name="create">true if parameters added for create scenario and false for update scenario.</param>
        /// <returns>PowerShell parameters.</returns>
        internal RuntimeDefinedParameterDictionary AddHttpErrorActionParameters(bool create = true)
        {
            var errorActionMethodAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = create ? true : false,
                    HelpMessage = "The Method for Http and Https Action types (GET, PUT, POST, HEAD or DELETE).",
                },
                new ValidateSetAttribute(Constants.HttpMethodGET, Constants.HttpMethodPUT, Constants.HttpMethodPOST, Constants.HttpMethodDELETE)
                {
                    IgnoreCase = true,
                }
            };

            var errorActionUriAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = create ? true : false,
                    HelpMessage = "The Uri for error job action.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionRequestBodyAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = false,
                    HelpMessage = "The Body for PUT and POST job actions.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionHeadersAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = false,
                    HelpMessage = "The header collection."
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            var errorActionHttpAuthenticationTypeAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = false,
                    HelpMessage = "The Http Authentication type."
                },
                new ValidateSetAttribute(Constants.HttpAuthenticationNone, Constants.HttpAuthenticationClientCertificate, Constants.HttpAuthenticationActiveDirectoryOAuth, Constants.HttpAuthenticationBasic)
                {
                    IgnoreCase = true
                }
            };

            this._errorActionMethod = new RuntimeDefinedParameter("ErrorActionMethod", typeof(string), errorActionMethodAttributes);
            this._errorActionUri = new RuntimeDefinedParameter("ErrorActionUri", typeof(Uri), errorActionUriAttributes);
            this._errorActionRequestBody = new RuntimeDefinedParameter("ErrorActionRequestBody", typeof(string), errorActionRequestBodyAttributes);
            this._errorActionHeaders = new RuntimeDefinedParameter("ErrorActionHeaders", typeof(Hashtable), errorActionHeadersAttributes);
            this._errorActionHttpAuthenticationType = new RuntimeDefinedParameter("ErrorActionHttpAuthenticationType", typeof(string), errorActionHttpAuthenticationTypeAttributes);

            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();
            runtimeDefinedParameterDictionary.Add("ErrorActionMethod", this._errorActionMethod);
            runtimeDefinedParameterDictionary.Add("ErrorActionUri", this._errorActionUri);
            runtimeDefinedParameterDictionary.Add("ErrorActionRequestBody", this._errorActionRequestBody);
            runtimeDefinedParameterDictionary.Add("ErrorActionHeaders", this._errorActionHeaders);
            runtimeDefinedParameterDictionary.Add("ErrorActionHttpAuthenticationType", this._errorActionHttpAuthenticationType);

            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionClientCertificateAuthenticationTypeParameters());
            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionBasicAuthenticationTypeParameters());
            runtimeDefinedParameterDictionary.AddRange(this.AddHttpErrorActionActiveDirectoryOAuthAuthenticationTypeParameters());

            return runtimeDefinedParameterDictionary;
        }
        /// <summary>
        /// Add service bus topic error action parameters.
        /// </summary>
        /// <param name="create">true if parameters added for create scenario and false for update scenario.</param>
        /// <returns>PowerShell parameters.</returns>
        internal RuntimeDefinedParameterDictionary AddServiceBusTopicErrorActionParameters(bool create = true)
        {
            var errorActionServiceBusTopicPathAttributes = new Collection<Attribute>
            {
                new ParameterAttribute
                {
                    Mandatory = create ? true : false,
                    HelpMessage = "Service bus topic path.",
                },
                new ValidateNotNullOrEmptyAttribute()
            };

            this._errorActionServiceBusTopicPath = new RuntimeDefinedParameter("ErrorActionServiceBusTopicPath", typeof(string), errorActionServiceBusTopicPathAttributes);

            var runTimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();
            runTimeDefinedParameterDictionary.Add("ErrorActionServiceBusTopicPath", this._errorActionServiceBusTopicPath);
            runTimeDefinedParameterDictionary.AddRange(this.AddServiceBusErrorActionParameters(create));

            return runTimeDefinedParameterDictionary;
        }
예제 #11
0
        public static ScriptBlock CloneWithIsolatedParameterDefinition(this ScriptBlock source)
        {
            var destination = source.Clone(false);

            var srcParamList = source.Get_RuntimeDefinedParameterList();
            var dstParamList = destination.Get_RuntimeDefinedParameterList();
            dstParamList = new List<RuntimeDefinedParameter>(srcParamList);
            destination.Set__runtimeDefinedParameterList(dstParamList);

            var srcParamDic = source.Get_RuntimeDefinedParameters();
            var dstParamDic = destination.Get_RuntimeDefinedParameters();
            dstParamDic = new RuntimeDefinedParameterDictionary();
            dstParamDic.AddRange(srcParamDic);
            destination.Set__runtimeDefinedParameters(dstParamDic);

            return destination;
        }
        /// <summary>
        /// Get conditional parameters depending on specified ErrorAction and/or type of http authentication.
        /// </summary>
        /// <returns>List of Powershell dynamic parameters.</returns>
        public object GetDynamicParameters()
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(this.HttpAuthenticationType))
            {
                if (this.HttpAuthenticationType == Constants.HttpAuthenticationClientCertificate)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpClientCertificateAuthenticationTypeParameters(create: false));
                }
                else if (this.HttpAuthenticationType == Constants.HttpAuthenticationBasic)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpBasicAuthenticationTypeParameters(create: false));
                }
                else if (this.HttpAuthenticationType == Constants.HttpAuthenticationActiveDirectoryOAuth)
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpActiveDirectoryOAuthAuthenticationTypeParameters(create: false));
                }
            }

            if (!string.IsNullOrWhiteSpace(this.ErrorActionType))
            {
                runtimeDefinedParameterDictionary.AddRange(this.AddErrorActionParameters(this.ErrorActionType, create: false));
            }
            
            return runtimeDefinedParameterDictionary;
        }
예제 #13
0
        /// <summary>
        /// Adds error action Powershell Parameters.
        /// </summary>
        /// <param name="errorActionType">Error action type.</param>
        /// <param name="create">true</param>
        /// <returns>PowerShell parameters.</returns>
        public RuntimeDefinedParameterDictionary AddErrorActionParameters(string errorActionType, bool create)
        {
            var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();

            if (!string.IsNullOrWhiteSpace(errorActionType))
            {
                if (errorActionType.Equals(Constants.HttpAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddHttpErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.StorageQueueAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddStorageQueueErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.ServiceBusQueueAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddServiceBusQueueErrorActionParameters(create));
                }
                else if (errorActionType.Equals(Constants.ServiceBusTopicAction, StringComparison.InvariantCultureIgnoreCase))
                {
                    runtimeDefinedParameterDictionary.AddRange(this.JobDynamicParameters.AddServiceBusTopicErrorActionParameters(create));
                }
            }

            return runtimeDefinedParameterDictionary;
        }