开发者

Get Perforce Credentials with .NET

Lots of times when I use an application that needs perforce access (Visual Studio, Unreal Editor) when I first use it, it will pop up a dialog where the user can enter their information (user, workspace, etc). Does anyone know of a开发者_如何转开发 way to do this in .NET?


What you're probably seeing is the login dialog from the Perforce SCC plugin. There is a standard API for IDEs (e.g. Visual Studio) to communicate with source control systems, but I believe you have to sign an NDA with (or at least pay a fee to) Microsoft in order to program against it.

what in general does the SCC API do?


P4COM and P4.Net are APIs that allow you to interface to Perforce with .NET languages (among others).


Perforce stores client side settings such as user, server:port, client etc in environment variables i.e P4USER, P4PORT, P4CLIENT.
On Windows, these variables are stored in the registry ( though if you ran on Windows under say Cygwin they will be stored and read as environment variables ).

You can view these variables using the perforce command p4 set - this will display all variables currently set on this machine.

For more info about all perforce variable then read this

Whether you call p4.exe directly through .NET by using System.Diagnostics.Process or whether you use one of the available libraries such as P4.NET or P4COM then any commands you run will use these settings as default.

If you want to override these default settings by popping up a dialog box in .NET then you'll need to code this yourself.

As an example using P4COM then you'd do the following:
1) Create your own dialog to get the info you want such user, client etc
2) Create a p4 instance i.e P4COM.p4 myp4 = new P4COM.p4();
3) Set the connection parameters you want i.e myP4.User = 'UserVal'
4) Call p4.connect i.e myp4.Connect();

Note that in P4COM, the various properties on a newly created p4 instance class will contain the current defaults for user, port etc so you could also read these first then present them in a dialog box to the user for them to change if needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜