Cae*_*sar 2 c# svn authentication sharpsvn
我正在使用SharpSVN.
我想将SVN凭证存储在pc中.
我尝试设置凭据更新默认凭据
using (SvnClient client = new SvnClient())
{
client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user", "password");
...
}
Run Code Online (Sandbox Code Playgroud)
但它不保存数据.
我发现SharpSvn提供了一个默认的GUI来输入凭据.该GUI具有存储数据的标志.这里是我找到信息的链接:
这里使用它的代码:
using (SvnClient client = new SvnClient())
{
// Bind the SharpSvn UI to our client for SSL certificate and credentials
SharpSvn.UI.SharpSvnUI.Bind(client, IWin32Window);
....
}
Run Code Online (Sandbox Code Playgroud)
但它是针对Windows.Forms和我使用WPF.此外,我无法使用此默认GUI.
有人现在怎么办?
谢谢!!
我找到了答案!
用于在使用中的计算机中保存凭据
using (SvnClient client = new SvnClient())
{
//Save localy new Authentication credentials
client.Authentication.UserNamePasswordHandlers
+= delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs args)
{
args.UserName = "username";
args.Password = "password";
args.Save= true;
};
}
Run Code Online (Sandbox Code Playgroud)
我经常找到在缓存中添加凭据的解决方案,但这不会在计算机中存储凭据.此凭据仅对SvnClient生命有效.我报告答案是否完整
using (SvnClient client = new SvnClient())
{
// Clear a previous authentication
client.Authentication.Clear();
client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user", "password");
}
Run Code Online (Sandbox Code Playgroud)
我在这里找到了部分答案
和这里:
http://sharpsvn.open.collab.net/ds/viewMessage.do?dsMessageId=140680&dsForumId=728
查看方法DialogUserNamePasswordHandler
http://sharpsvn.open.collab.net/svn/sharpsvn/trunk/src/SharpSvn.UI/SvnClientUIHandler.cs
供访问使用: