Exemplo n.º 1
0
 private void SetSelectedCredential(CacheCredential credential)
 {
     txtAccessKey.Text   = credential.AccessKey;
     txtEndpoint.Text    = credential.EndpointName;
     txtFriendyName.Text = credential.FriendlyName;
     btnDelete.Enabled   = true;
     btnAdd.Text         = "Edit";
 }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            CacheCredential cred = GetSelectedCredential();

            if (MessageBox.Show(string.Format("Are you sure you want to delete the stored credentials '{0}'?", cred.FriendlyName), "Delete stored credential?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                _credentials.Credentials.Remove(cred);
                lvwCredentials.Items.RemoveAt(lvwCredentials.SelectedIndices[0]);
            }
        }
Exemplo n.º 3
0
        private void lvwCredentials_SelectedIndexChanged(object sender, EventArgs e)
        {
            CacheCredential credential = GetSelectedCredential();

            if (credential == null)
            {
                ClearSelectedCredential();
            }
            else
            {
                SetSelectedCredential(credential);
            }
            CheckRemoveButton();
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFriendyName.Text))
            {
                MessageBox.Show("Please provide a friendly name.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(txtEndpoint.Text))
            {
                MessageBox.Show("Please provide an endpoint.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(txtAccessKey.Text))
            {
                MessageBox.Show("Please provide an access key.", "Cannot add stored credential", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            bool            addMode = false;
            CacheCredential cred    = GetSelectedCredential();

            if (cred == null)
            {
                addMode = true;
                cred    = new CacheCredential();
            }

            cred.AccessKey    = txtAccessKey.Text.Trim();
            cred.EndpointName = txtEndpoint.Text.Trim();
            cred.FriendlyName = txtFriendyName.Text.Trim();
            if (addMode)
            {
                _credentials.Credentials.Add(cred);

                ListViewItem lvi = new ListViewItem(cred.FriendlyName);
                lvi.SubItems.Add(cred.EndpointName);

                lvwCredentials.Items.Add(lvi);

                lvwCredentials.Items[lvwCredentials.Items.Count - 1].Selected = true;
            }
            else
            {
                lvwCredentials.SelectedItems[0].SubItems[0].Text = cred.FriendlyName;
                lvwCredentials.SelectedItems[0].SubItems[1].Text = cred.EndpointName;
            }
        }
Exemplo n.º 5
0
        private bool CheckItemDirty()
        {
            CacheCredential credential = GetSelectedCredential();

            if (credential == null)
            {
                return(!string.IsNullOrWhiteSpace(txtAccessKey.Text) || !string.IsNullOrWhiteSpace(txtEndpoint.Text) || !string.IsNullOrWhiteSpace(txtFriendyName.Text));
            }
            if (txtAccessKey.Text != credential.AccessKey)
            {
                return(true);
            }
            if (txtEndpoint.Text != credential.EndpointName)
            {
                return(true);
            }
            if (txtFriendyName.Text != credential.FriendlyName)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        public DataCacheFactoryConfiguration GetDataCacheConfiguration(int index)
        {
            CacheCredential credential = _credentials.Credentials[index];

            return(GetDataCacheConfiguration(credential.EndpointName, credential.AccessKey));
        }