예제 #1
0
        public override string ReadLine()
        {
            MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new ReadLineMessage(), true);

            this.OnMessageCreated(messageCreatedEventArg);
            return((string)messageCreatedEventArg.Reply);
        }
예제 #2
0
        public override SecureString ReadLineAsSecureString()
        {
            MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new ReadLineAsSecureStringMessage(), true);

            this.OnMessageCreated(messageCreatedEventArg);
            return((SecureString)messageCreatedEventArg.Reply);
        }
예제 #3
0
        private void OnMessageCreated(MessageCreatedEventArgs e)
        {
            EventHandler <MessageCreatedEventArgs> eventHandler = this.MessageCreated;

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
예제 #4
0
        public override int PromptForChoice(string caption, string message, Collection <ChoiceDescription> choices, int defaultChoice)
        {
            int reply;

            PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForChoice(): Enter");
            try
            {
                MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptForChoiceMessage(caption, message, choices, defaultChoice), true);
                this.OnMessageCreated(messageCreatedEventArg);
                reply = (int)messageCreatedEventArg.Reply;
            }
            finally
            {
                PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForChoice(): Exit");
            }
            return(reply);
        }
예제 #5
0
        public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options)
        {
            PSCredential reply;
            string       str;

            PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForCredential(): Enter");
            try
            {
                if (string.IsNullOrEmpty(targetName))
                {
                    bool   flag = (allowedCredentialTypes & PSCredentialTypes.Domain) == PSCredentialTypes.Domain;
                    string str1 = "PromptForCredential()";
                    string str2 = "domainCredentials";
                    if (flag)
                    {
                        str = "true";
                    }
                    else
                    {
                        str = "false";
                    }
                    PowwaEvents.PowwaEVENT_DEBUG_LOG1(str1, str2, str);
                    MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptForCredentialMessage(caption, message, userName, flag), true);
                    this.OnMessageCreated(messageCreatedEventArg);
                    reply = (PSCredential)messageCreatedEventArg.Reply;
                }
                else
                {
                    PowwaEvents.PowwaEVENT_DEBUG_LOG1("PromptForCredential(): Invalid Argument", "targetName", "null");
                    throw new NotSupportedException(Resources.PromptForCredentialTargetNameNotSupported);
                }
            }
            finally
            {
                PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForCredential(): Exit");
            }
            return(reply);
        }
예제 #6
0
		private void OnMessageCreated(MessageCreatedEventArgs e)
		{
			EventHandler<MessageCreatedEventArgs> eventHandler = this.MessageCreated;
			if (eventHandler != null)
			{
				eventHandler(this, e);
			}
		}
예제 #7
0
 private void OnClientMessageCreated(MessageCreatedEventArgs e)
 {
     e.Reply = this.PostClientMessage(e.Message, e.IsInputMessage);
 }
예제 #8
0
        public override Dictionary <string, PSObject> Prompt(string caption, string message, Collection <FieldDescription> descriptions)
        {
            bool flag = false;
            Dictionary <string, PSObject> reply;

            PowwaEvents.PowwaEVENT_DEBUG_LOG0("Prompt(): Enter");
            try
            {
                if (descriptions != null)
                {
                    if (descriptions.Count != 0)
                    {
                        PromptFieldDescription[] promptFieldDescriptionArray = new PromptFieldDescription[descriptions.Count];
                        int num = 0;
                        while (num < descriptions.Count)
                        {
                            if (descriptions[num] != null)
                            {
                                Type            fieldType       = PowwaHostUserInterface.GetFieldType(descriptions[num], out flag);
                                PromptFieldType promptFieldType = PromptFieldType.String;
                                if (fieldType != typeof(SecureString))
                                {
                                    if (fieldType == typeof(PSCredential))
                                    {
                                        promptFieldType = PromptFieldType.Credential;
                                    }
                                }
                                else
                                {
                                    promptFieldType = PromptFieldType.SecureString;
                                }
                                PromptFieldDescription promptFieldDescription = new PromptFieldDescription();
                                promptFieldDescription.Name                  = descriptions[num].Name;
                                promptFieldDescription.Label                 = descriptions[num].Label;
                                promptFieldDescription.HelpMessage           = descriptions[num].HelpMessage;
                                promptFieldDescription.PromptFieldType       = promptFieldType;
                                promptFieldDescription.PromptFieldTypeIsList = flag;
                                promptFieldDescriptionArray[num]             = promptFieldDescription;
                                num++;
                            }
                            else
                            {
                                object[] objArray = new object[1];
                                objArray[0] = num;
                                string str = string.Format(CultureInfo.InvariantCulture, "descriptions[{0}]", objArray);
                                PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Description", str, "null");
                                throw new ArgumentNullException(str);
                            }
                        }
                        MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptMessage(caption, message, promptFieldDescriptionArray), true);
                        this.OnMessageCreated(messageCreatedEventArg);
                        reply = (Dictionary <string, PSObject>)messageCreatedEventArg.Reply;
                    }
                    else
                    {
                        int count = descriptions.Count;
                        PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Argument", "Descriptions.Count", count.ToString(CultureInfo.InvariantCulture));
                        throw new ArgumentException("descriptions cannot be an empty array", "descriptions");
                    }
                }
                else
                {
                    PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Argument", "Descriptions", "null");
                    throw new ArgumentNullException("descriptions");
                }
            }
            finally
            {
                PowwaEvents.PowwaEVENT_DEBUG_LOG0("Prompt(): Exit");
            }
            return(reply);
        }
예제 #9
0
		public override Dictionary<string, PSObject> Prompt(string caption, string message, Collection<FieldDescription> descriptions)
		{
			bool flag = false;
			Dictionary<string, PSObject> reply;
			PowwaEvents.PowwaEVENT_DEBUG_LOG0("Prompt(): Enter");
			try
			{
				if (descriptions != null)
				{
					if (descriptions.Count != 0)
					{
						PromptFieldDescription[] promptFieldDescriptionArray = new PromptFieldDescription[descriptions.Count];
						int num = 0;
						while (num < descriptions.Count)
						{
							if (descriptions[num] != null)
							{
								Type fieldType = PowwaHostUserInterface.GetFieldType(descriptions[num], out flag);
								PromptFieldType promptFieldType = PromptFieldType.String;
								if (fieldType != typeof(SecureString))
								{
									if (fieldType == typeof(PSCredential))
									{
										promptFieldType = PromptFieldType.Credential;
									}
								}
								else
								{
									promptFieldType = PromptFieldType.SecureString;
								}
								PromptFieldDescription promptFieldDescription = new PromptFieldDescription();
								promptFieldDescription.Name = descriptions[num].Name;
								promptFieldDescription.Label = descriptions[num].Label;
								promptFieldDescription.HelpMessage = descriptions[num].HelpMessage;
								promptFieldDescription.PromptFieldType = promptFieldType;
								promptFieldDescription.PromptFieldTypeIsList = flag;
								promptFieldDescriptionArray[num] = promptFieldDescription;
								num++;
							}
							else
							{
								object[] objArray = new object[1];
								objArray[0] = num;
								string str = string.Format(CultureInfo.InvariantCulture, "descriptions[{0}]", objArray);
								PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Description", str, "null");
								throw new ArgumentNullException(str);
							}
						}
						MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptMessage(caption, message, promptFieldDescriptionArray), true);
						this.OnMessageCreated(messageCreatedEventArg);
						reply = (Dictionary<string, PSObject>)messageCreatedEventArg.Reply;
					}
					else
					{
						int count = descriptions.Count;
						PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Argument", "Descriptions.Count", count.ToString(CultureInfo.InvariantCulture));
						throw new ArgumentException("descriptions cannot be an empty array", "descriptions");
					}
				}
				else
				{
					PowwaEvents.PowwaEVENT_DEBUG_LOG1("Prompt(): Invalid Argument", "Descriptions", "null");
					throw new ArgumentNullException("descriptions");
				}
			}
			finally
			{
				PowwaEvents.PowwaEVENT_DEBUG_LOG0("Prompt(): Exit");
			}
			return reply;
		}
예제 #10
0
		public override SecureString ReadLineAsSecureString()
		{
			MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new ReadLineAsSecureStringMessage(), true);
			this.OnMessageCreated(messageCreatedEventArg);
			return (SecureString)messageCreatedEventArg.Reply;
		}
예제 #11
0
		public override string ReadLine()
		{
			MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new ReadLineMessage(), true);
			this.OnMessageCreated(messageCreatedEventArg);
			return (string)messageCreatedEventArg.Reply;
		}
예제 #12
0
		public override PSCredential PromptForCredential(string caption, string message, string userName, string targetName, PSCredentialTypes allowedCredentialTypes, PSCredentialUIOptions options)
		{
			PSCredential reply;
			string str;
			PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForCredential(): Enter");
			try
			{
				if (string.IsNullOrEmpty(targetName))
				{
					bool flag = (allowedCredentialTypes & PSCredentialTypes.Domain) == PSCredentialTypes.Domain;
					string str1 = "PromptForCredential()";
					string str2 = "domainCredentials";
					if (flag)
					{
						str = "true";
					}
					else
					{
						str = "false";
					}
					PowwaEvents.PowwaEVENT_DEBUG_LOG1(str1, str2, str);
					MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptForCredentialMessage(caption, message, userName, flag), true);
					this.OnMessageCreated(messageCreatedEventArg);
					reply = (PSCredential)messageCreatedEventArg.Reply;
				}
				else
				{
					PowwaEvents.PowwaEVENT_DEBUG_LOG1("PromptForCredential(): Invalid Argument", "targetName", "null");
					throw new NotSupportedException(Resources.PromptForCredentialTargetNameNotSupported);
				}
			}
			finally
			{
				PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForCredential(): Exit");
			}
			return reply;
		}
예제 #13
0
		public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices, int defaultChoice)
		{
			int reply;
			PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForChoice(): Enter");
			try
			{
				MessageCreatedEventArgs messageCreatedEventArg = new MessageCreatedEventArgs(new PromptForChoiceMessage(caption, message, choices, defaultChoice), true);
				this.OnMessageCreated(messageCreatedEventArg);
				reply = (int)messageCreatedEventArg.Reply;
			}
			finally
			{
				PowwaEvents.PowwaEVENT_DEBUG_LOG0("PromptForChoice(): Exit");
			}
			return reply;
		}