Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
 public SqlLoginPool()
 {
     LoginPool = new SqlLogin[MAXLOGINS];
 }
Exemplo n.º 4
0
        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();
            }
        }