Esempio n. 1
0
        public override void Execute(CmdletOperationBase cmdlet)
        {
            bool flag;

            ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
            bool          flag1         = false;
            bool          flag2         = false;
            CimPromptType cimPromptType = this.prompt;

            switch (cimPromptType)
            {
            case CimPromptType.None:
            {
                flag = cmdlet.ShouldProcess(this.message);
                if (!flag)
                {
                    if (flag)
                    {
                        break;
                    }
                    this.responseType = CimResponseType.None;
                    break;
                }
                else
                {
                    this.responseType = CimResponseType.Yes;
                    break;
                }
            }

            case CimPromptType.Critical:
            {
                flag = cmdlet.ShouldContinue(this.message, "caption", ref flag1, ref flag2);
                if (!flag1)
                {
                    if (!flag2)
                    {
                        if (!flag)
                        {
                            if (flag)
                            {
                                break;
                            }
                            this.responseType = CimResponseType.None;
                            break;
                        }
                        else
                        {
                            this.responseType = CimResponseType.Yes;
                            break;
                        }
                    }
                    else
                    {
                        this.responseType = CimResponseType.NoToAll;
                        break;
                    }
                }
                else
                {
                    this.responseType = CimResponseType.YesToAll;
                    break;
                }
            }
            }
            this.OnComplete();
        }
Esempio n. 2
0
        /// <summary>
        /// <para>
        /// Prompt user with the given message and prepared whatif message.
        /// </para>
        /// </summary>
        /// <param name="cmdlet">
        /// cmdlet wrapper object, to which write result.
        /// <see cref="CmdletOperationBase"/> for details.
        /// </param>
        public override void Execute(CmdletOperationBase cmdlet)
        {
            ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");

            bool yestoall = false;
            bool notoall = false;
            bool result = false;

            switch (this.prompt)
            {
                case CimPromptType.Critical:
                    // NOTES: prepare the whatif message and caption
                    try
                    {
                        result = cmdlet.ShouldContinue(message, "caption", ref yestoall, ref notoall);
                        if (yestoall)
                        {
                            this.responseType = CimResponseType.YesToAll;
                        }
                        else if (notoall)
                        {
                            this.responseType = CimResponseType.NoToAll;
                        }
                        else if (result)
                        {
                            this.responseType = CimResponseType.Yes;
                        }
                        else if (!result)
                        {
                            this.responseType = CimResponseType.No;
                        }
                    }
                    catch
                    {
                        this.responseType = CimResponseType.NoToAll;
                        throw;                        
                    }
                    finally
                    {
                        // unblocking the waiting thread
                        this.OnComplete();
                    }                    
                    break;
                case CimPromptType.Normal:
                    try
                    {
                        result = cmdlet.ShouldProcess(message);
                        if (result)
                        {
                            this.responseType = CimResponseType.Yes;
                        }
                        else if (!result)
                        {
                            this.responseType = CimResponseType.No;
                        }
                    }
                    catch
                    {
                        this.responseType = CimResponseType.NoToAll;
                        throw;                        
                    }
                    finally
                    {
                        // unblocking the waiting thread
                        this.OnComplete();
                    }                     
                    break;
                default:
                    break;
            }
            this.OnComplete();
        }  
Esempio n. 3
0
        /// <summary>
        /// <para>
        /// Prompt user with the given message and prepared whatif message.
        /// </para>
        /// </summary>
        /// <param name="cmdlet">
        /// cmdlet wrapper object, to which write result.
        /// <see cref="CmdletOperationBase"/> for details.
        /// </param>
        public override void Execute(CmdletOperationBase cmdlet)
        {
            ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");

            bool yestoall = false;
            bool notoall  = false;
            bool result   = false;

            switch (this.prompt)
            {
            case CimPromptType.Critical:
                // NOTES: prepare the whatif message and caption
                try
                {
                    result = cmdlet.ShouldContinue(Message, "caption", ref yestoall, ref notoall);
                    if (yestoall)
                    {
                        this.responseType = CimResponseType.YesToAll;
                    }
                    else if (notoall)
                    {
                        this.responseType = CimResponseType.NoToAll;
                    }
                    else if (result)
                    {
                        this.responseType = CimResponseType.Yes;
                    }
                    else if (!result)
                    {
                        this.responseType = CimResponseType.No;
                    }
                }
                catch
                {
                    this.responseType = CimResponseType.NoToAll;
                    throw;
                }
                finally
                {
                    // unblocking the waiting thread
                    this.OnComplete();
                }

                break;

            case CimPromptType.Normal:
                try
                {
                    result = cmdlet.ShouldProcess(Message);
                    if (result)
                    {
                        this.responseType = CimResponseType.Yes;
                    }
                    else if (!result)
                    {
                        this.responseType = CimResponseType.No;
                    }
                }
                catch
                {
                    this.responseType = CimResponseType.NoToAll;
                    throw;
                }
                finally
                {
                    // unblocking the waiting thread
                    this.OnComplete();
                }

                break;

            default:
                break;
            }

            this.OnComplete();
        }
Esempio n. 4
0
		public override void Execute(CmdletOperationBase cmdlet)
		{
			bool flag;
			ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet");
			bool flag1 = false;
			bool flag2 = false;
			CimPromptType cimPromptType = this.prompt;
			switch (cimPromptType)
			{
				case CimPromptType.None:
				{
					flag = cmdlet.ShouldProcess(this.message);
					if (!flag)
					{
						if (flag)
						{
							break;
						}
						this.responseType = CimResponseType.None;
						break;
					}
					else
					{
						this.responseType = CimResponseType.Yes;
						break;
					}
				}
				case CimPromptType.Critical:
				{
					flag = cmdlet.ShouldContinue(this.message, "caption", ref flag1, ref flag2);
					if (!flag1)
					{
						if (!flag2)
						{
							if (!flag)
							{
								if (flag)
								{
									break;
								}
								this.responseType = CimResponseType.None;
								break;
							}
							else
							{
								this.responseType = CimResponseType.Yes;
								break;
							}
						}
						else
						{
							this.responseType = CimResponseType.NoToAll;
							break;
						}
					}
					else
					{
						this.responseType = CimResponseType.YesToAll;
						break;
					}
				}
			}
			this.OnComplete();
		}