static bool TryGetPassphrase (URIish uri, CredentialItem[] items, out CredentialItem.StringType passphraseItem) { var actualUrl = new Uri (uri.ToString ()); var passphrase = (CredentialItem.StringType) items.FirstOrDefault (i => i is CredentialItem.StringType); if (items.Length == 1 && passphrase != null) { passphraseItem = passphrase; var passphraseValue = PasswordService.GetWebPassword (actualUrl); if (passphraseValue != null) { passphrase.SetValue (passphraseValue); return true; } } else { passphraseItem = null; } return false; }
static bool TryGetUsernamePassword (URIish uri, CredentialItem[] items, out CredentialItem.Password passwordItem) { var actualUrl = new Uri (uri.ToString ()); var username = (CredentialItem.Username) items.FirstOrDefault (i => i is CredentialItem.Username); var password = (CredentialItem.Password) items.FirstOrDefault (i => i is CredentialItem.Password); if (items.Length == 2 && username != null && password != null) { passwordItem = password; var cred = PasswordService.GetWebUserNameAndPassword (actualUrl); if (cred != null) { username.SetValue (cred.Item1); password.SetValueNoCopy (cred.Item2.ToArray ()); return true; } } else { passwordItem = null; } return false; }