Raised when Perforce is prompting for a response.
The event handler receives an argument of type P4PromptEventArgs containing data related to this event. The following P4PromptEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Message | The message from Perforce. |
Response | The value to respond to Perforce with. |
Handle Perforce "prompts". Prompts are from commands that ask the user to respond, such as:
The following sample will change the user's password.
public class PasswordSetter { private P4Connection _p4 = null; private string _oldPassword = ""; private string _newPassword = ""; PasswordSetter(P4Connection p4) { _p4 = p4; } public void SetPassword(string OldPassword, string NewPassword) { OnPromptEventHandler eh = new OnPromptEventHandler(OnPrompt); _p4.OnPrompt += eh; _oldPassword = OldPassword; _newPassword = NewPassword; //run passwd P4UnParsedRecordSet r = _p4.RunUnParsed("passwd"); //Clear the event just in case _p4.OnPrompt -= eh; //Clear the passwords from memory _newPassword = ""; _oldPassword = ""; } private void OnPrompt(object sender, P4PromptEventArgs e) { switch (e.Message) { case ("Enter old password: "): e.Response = _oldPassword; break; case ("Enter new password: "): e.Response = _newPassword; break; case ("Re-enter new password: "): e.Response = _newPassword; break; } } }
P4Connection Class | P4API Namespace