6 using MonoDevelop
.Core
;
7 using MonoDevelop
.Ide
.Gui
;
8 using MonoDevelop
.Ide
.Gui
.Pads
;
9 using MonoDevelop
.Components
.Commands
;
11 using Microsoft
.TeamFoundation
.Client
;
12 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
13 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
14 using Gtk
.TeamFoundation
;
16 namespace MonoDevelop
.TeamFoundation
18 public class TeamFoundationPad
: AbstractPadContent
, IVersionControlServerFactory
20 CredentialCache credentialCache
= new CredentialCache();
21 ExploreView exploreView
;
23 public TeamFoundationPad() : base ("Team Foundation Browser")
25 exploreView
= new ExploreView(this, 50);
26 exploreView
.ShowAll();
29 public override Gtk
.Widget Control
{
30 get { return exploreView; }
33 public VersionControlServer
GetVersionControlServer(string url
)
35 ICredentials creds
= GetCredentials(url
);
36 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, creds
);
37 return tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
40 protected NetworkCredential
GetCredentials(string url
)
42 Uri uri
= new Uri(url
);
43 NetworkCredential creds
= credentialCache
.GetCredential(uri
, "NTLM");
44 if (creds
!= null) return creds
;
46 string login
= TeamFoundationSettings
.Current
.Get(url
);
47 string userinfo
= String
.Empty
;
49 string username
= String
.Empty
;
50 string domain
= String
.Empty
;
51 string password
= String
.Empty
;
53 int comma
= login
.IndexOf(",");
56 userinfo
= login
.Substring(0, comma
);
57 password
= login
.Substring(comma
+1);
59 else userinfo
= login
;
61 // try to find domain portion if given
62 int slash
= userinfo
.IndexOf('\\');
65 domain
= userinfo
.Substring(0, slash
);
66 username
= userinfo
.Substring(slash
+1);
70 int atsign
= userinfo
.IndexOf('@');
73 username
= userinfo
.Substring(0, atsign
);
74 domain
= userinfo
.Substring(atsign
+1);
76 else username
= userinfo
;
79 creds
= new NetworkCredential(username
, password
, domain
);
80 credentialCache
.Add(uri
, "NTLM", creds
);