Raised when Perforce is prompting for a response.
Namespace:
P4APIAssembly: p4api (in p4api)
Version: 1.0.0.0 (1.0.0)
Syntax
C# |
---|
public event OnPromptEventHandler OnPrompt |
Remarks
Handle Perforce "prompts". Prompts are from commands that ask the user to respond, such as:
login passwd resolve (without an -a* switch)
Examples
The following sample will change the user's password.
CopyC#
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; } } }