/// <summary> /// Implementation of Equals /// </summary> /// <param name="obj">Object to compare for equality</param> /// <returns></returns> override public bool Equals(object obj) { SqlLogin sl = obj as SqlLogin; if (sl == null) { return(false); } if ((sl.Address == Address) && (sl.Login == Login)) { return(true); } return(false); }
private void frmLoginInfo_Closing(object sender, System.ComponentModel.CancelEventArgs e) { /* * Serialize Logins */ if (this.DialogResult == DialogResult.OK) { TextWriter twXML = new StreamWriter(sConnectionsFile); ((FormMain)this.Owner).ShowInfoMessage("Serializing connection preferences..."); SqlLogin slLastConnection = new SqlLogin(); slLastConnection.Address = cbServer.Text; slLastConnection.Login = txtLogin.Text; slLastConnection.IsLastUsed = true; if (!cbServer.Items.Contains(slLastConnection)) { cbServer.Items.Insert(0, slLastConnection); } else { SqlLogin slFound; slFound = cbServer.Items[cbServer.Items.IndexOf(slLastConnection)] as SqlLogin; slFound.IsLastUsed = true; } while (cbServer.Items.Count > SqlLoginPool.MAXLOGINS) { cbServer.Items.RemoveAt(cbServer.Items.Count - 1); } SqlLoginPool slpLogins = new SqlLoginPool(); cbServer.Items.CopyTo(slpLogins.LoginPool, 0); XmlSerializer xsLogins = new XmlSerializer(typeof(SqlLoginPool)); xsLogins.Serialize(twXML, slpLogins); twXML.Close(); } }
public SqlLoginPool() { LoginPool = new SqlLogin[MAXLOGINS]; }
private void frmLoginInfo_Closing(object sender, System.ComponentModel.CancelEventArgs e) { /* * Serialize Logins */ if (this.DialogResult == DialogResult.OK) { TextWriter twXML = new StreamWriter(sConnectionsFile); ((FormMain)this.Owner).ShowInfoMessage("Serializing connection preferences..."); SqlLogin slLastConnection = new SqlLogin(); slLastConnection.Address = cbServer.Text; slLastConnection.Login = txtLogin.Text; slLastConnection.IsLastUsed = true; if (!cbServer.Items.Contains(slLastConnection)) { cbServer.Items.Insert(0, slLastConnection); } else { SqlLogin slFound; slFound = cbServer.Items[cbServer.Items.IndexOf(slLastConnection)] as SqlLogin; slFound.IsLastUsed = true; } while (cbServer.Items.Count > SqlLoginPool.MAXLOGINS) { cbServer.Items.RemoveAt(cbServer.Items.Count-1); } SqlLoginPool slpLogins = new SqlLoginPool(); cbServer.Items.CopyTo(slpLogins.LoginPool, 0); XmlSerializer xsLogins = new XmlSerializer(typeof(SqlLoginPool)); xsLogins.Serialize(twXML, slpLogins); twXML.Close(); } }