Represents a Perforce 'Form' object.
Namespace:
P4APIAssembly: p4api (in p4api)
Version: 1.0.0.0 (1.0.0)
Syntax
C# |
---|
public class P4Form : P4Record |
Remarks
Forms are the things that pop-up in an editor when run from a command line. In
P4.Net (and most other Perforce APIs), you do not need to parse/format the text manually.
Instead, you can get/set the fields using the Fields and ArrayFields collections.
The following is a list of common form commands:client branch label job user group protect triggers branch
When fetching or saving a form, do not use the '-o' and '-i' flags. P4.Net will automatically include them.
Examples
The following example updates the current client. It changes the client root, and adds a line to the view.
CopyC#
P4Connection p4 = new P4Connection(); p4.Connect(); P4Form MyClient = p4.Fetch_Form("client"); //Change the root and properties MyClient["Root"] = @"C:\p4\P4.NetClient"; MyClient["Description"] = "Created from P4.Net!"; //Fetch the clientName (for use later in building the view spec). string clientName = MyClient["Client"]; // Build a new array, that has one more element than the current view string[] NewView = new string[MyClient.ArrayFields["View"].Length + 1]; // Copy the existing view lines to the new array MyClient.ArrayFields["View"].CopyTo(NewView,0); // Set the new view line NewView[NewView.Length - 1] = string.Format("//depot/newpath/... //{0}/newpath/...", clientName); MyClient.ArrayFields["View"] = NewView; // Save the form P4UnParsedRecordSet MyResult = p4.Save_Form(MyClient); p4.Disconnect();