public void TestStorage() { string value; Store.Write(null, "<?a", "b"); Assert.IsTrue(Store.Read(null, "<?a", out value)); Assert.AreEqual("b", value); Assert.IsTrue(Store.Read(String.Empty, "<?a", out value)); Assert.AreEqual("b", value); Store.Write(null, "<?a", "b"); Assert.IsTrue(Store.Read(null, "<?a", out value)); Assert.AreEqual("b", value); Assert.IsTrue(Store.Read(String.Empty, "<?a", out value)); Assert.AreEqual("b", value); Store.Write(">?1/\\", "<?a", "c"); Assert.IsTrue(Store.Read(String.Empty, "<?a", out value)); Assert.AreEqual("b", value); Assert.IsTrue(Store.Read(">?1/\\", "<?a", out value)); Assert.AreEqual("c", value); Store.Delete(">?1/\\", "<?a"); Assert.IsFalse(Store.Read(">?1/\\", "<?a", out value)); Store.Delete(null, "<?a"); Assert.IsFalse(Store.Read(null, "<?a", out value)); Assert.IsFalse(Store.Read(String.Empty, "<?a", out value)); }
/// <summary> Retrieves the named defaultValue from the storage </summary> public object GetValue(string name, Type type, object defaultValue) { try { string text; object value; if (_store.Read(ContextPath, name, out text) && StringUtils.TryParse(text, type, out value)) { return(value); } } catch { } return(defaultValue); }
private static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) { return(true); } var request = sender as WebRequest; if (request == null || certificate == null) { return(false); } bool isAllowed; string allowed, urn = String.Format("{0}:{1}", request.RequestUri.Host, request.RequestUri.Port); if (Storage.Read(urn, certificate.GetCertHashString(), out allowed) && bool.TryParse(allowed, out isAllowed)) { return(isAllowed); } string sslErrorDesc = String.Empty; if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) == SslPolicyErrors.RemoteCertificateChainErrors) { sslErrorDesc += Resources.RemoteCertificateChainErrors; } else if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNameMismatch) == SslPolicyErrors.RemoteCertificateNameMismatch) { sslErrorDesc += Resources.RemoteCertificateNameMismatch; } else if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) == SslPolicyErrors.RemoteCertificateNotAvailable) { sslErrorDesc += Resources.RemoteCertificateNotAvailable; } sslErrorDesc = String.Format(Resources.SslErrorDescPromptFormat, urn, sslErrorDesc, certificate.Subject, certificate.GetCertHashString()); DialogResult dr = MessageBox.Show(sslErrorDesc, "SSL Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2); if (dr != DialogResult.Yes) { return(false); } Storage.Write(urn, certificate.GetCertHashString(), true.ToString()); return(true); }
private void LoadUsers() { string usersList; if (_store.Read(GetType().FullName, ALL_USERS_KEY, out usersList)) { foreach (string suser in usersList.Split(';')) { if (_lookupUsers) { string fullName; if (_store.Read(GetType().FullName, suser, out fullName)) { _knownUsers[suser] = new JiraUser(suser, fullName); } } else { _knownUsers[suser] = new JiraUser(suser, suser); } } } }
private void LoadUsers() { string usersList; // Next line gets the value from the Registry at: Computer/HKEY_USERS/.../Software/httpstortoisegit.org/TortoiseGit/JiraSVN.Jira.JiraConnection if (_store.Read(this.GetType().FullName, ALL_USERS_KEY, out usersList)) { foreach (string suser in usersList.Split(';')) { if (_lookupUsers) { string fullName; if (_store.Read(this.GetType().FullName, suser, out fullName)) { _knownUsers[suser] = new JiraUser(suser, fullName); } } else { _knownUsers[suser] = new JiraUser(suser, suser); } } } }
/// <summary> returns true if the value exists </summary> protected virtual bool HasState(Guid transferId, string name) { string value; return(_storage.Read(transferId.ToString("N"), name, out value)); }